Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function render (alert) {
const data = cloneDeep(alert.priceHistory);
// hack to show graph if there is only one data point
if (data.length === 1) {
data.push(cloneDeep(data[0]));
data[1].time = data[0].time + 1;
}
const times = data.map(d => d.time);
const minTime = Math.min(...times);
const maxTime = Math.max(...times);
const maxPrice = Math.ceil(Math.max(...data.map(d => d.price)) / 50) * 50;
const Graph = e('div', null, [
e(V.VictoryChart, {
domainPadding: 20,
padding: { top: 10, right: 50, bottom: 50, left: 50 },
theme: Theme
}, [
e(V.VictoryAxis, {
domainPadding: 0,
tickFormat: date => dateFormat(new Date(date), 'm/d', true)
}),
e(V.VictoryAxis, {
crossAxis: false,
dependentAxis: true,
domain: [ 0, maxPrice ],
tickFormat: tick => '$' + tick
}),
e(V.VictoryLine, {
data,
const Victory = require('victory');
const Axis = require('victory').VictoryAxis;
const Chart = Victory.VictoryChart;
const chartMap = {
line: Victory.VictoryLine,
scatter: Victory.VictoryScatter
};
const getStyles = (props) => {
switch (props.type) {
case 'line':
return {
stroke: props.foregroundColor
};
case 'scatter':
return {
fill: props.foregroundColor
};