Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createChart(newProps?: Props) {
const props = newProps || this.props;
const config = initChart(Object.assign({
hideEndButton: (hide) =>
this.props.parent.setState({ endButtonShown: !hide }),
}, props));
this.chart = this.props.parent.chart =
new Highcharts.StockChart(this.chartDiv, config, (chart) => {
if (!props.noData && props.ticks.length === 0) {
chart.showLoading();
}
});
this.eventListeners = props.events.map(e => ({
type: e.type,
handler: ev => e.handler(ev, this.chart),
}));
this.eventListeners.forEach(e => this.chartDiv.addEventListener(e.type, e.handler));
}
let currTime = new Date().getTime();
let minVal = nextProps.priceChartCurrentPeriod
? currTime - 1000 * nextProps.priceChartCurrentPeriod
: min;
if (nextProps.priceChartCurrentPeriod) {
this.chart.xAxis[0].setExtremes(minVal, currTime);
this.chart.xAxis[0].update({
min: minVal,
max: currTime,
range: currTime - minVal
});
this.chart.xAxis[0].setExtremes();
} else {
this.chart = new Highstock.StockChart('chart01', {
global: {
useUTC: false
},
colors: [
{
linearGradient: {
x1: 1,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[
0, '#2f97e9'
],
[1, '#00fe95']
const createChart = (renderTo, params) => {
const config = initChart(params);
const chart = new Highcharts.StockChart(renderTo, config);
if (params.type === 'candlestick') {
chart.xAxis[0].update({
minRange: 10 * 60 * 1000,
});
}
return chart;
};
let currTime = new Date().getTime();
let minVal = nextProps.priceChartCurrentPeriod
? currTime - 1000 * nextProps.priceChartCurrentPeriod
: min;
if (nextProps.priceChartCurrentPeriod) {
this.chart.xAxis[0].setExtremes(minVal, currTime);
this.chart.xAxis[0].update({
min: minVal,
max: currTime,
range: currTime - minVal
});
this.chart.xAxis[0].setExtremes();
} else {
this.chart = new Highstock.StockChart('chart01', {
global: {
useUTC: false
},
colors: [
{
linearGradient: {
x1: 1,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[
0, '#2f97e9'
],
[1, '#00fe95']