Fix null pointer in chart JS [skip ci]

This commit is contained in:
James Cole
2018-03-11 18:40:08 +01:00
parent dd6a6a565f
commit 93aa5b7753

View File

@@ -294,31 +294,33 @@ function drawAChart(URI, container, chartType, options, colorData) {
lineAtIndex: [], lineAtIndex: [],
annotation: {}, annotation: {},
}; };
if (drawVerticalLine !== '') { if (typeof drawVerticalLine !== 'undefined') {
// draw line using annotation plugin. if (drawVerticalLine !== '') {
console.log('Will draw line'); // draw line using annotation plugin.
chartOpts.options.annotation = { console.log('Will draw line');
annotations: [{ chartOpts.options.annotation = {
type: 'line', annotations: [{
id: 'a-line-1', type: 'line',
mode: 'vertical', id: 'a-line-1',
scaleID: 'x-axis-0', mode: 'vertical',
value: drawVerticalLine, scaleID: 'x-axis-0',
borderColor: 'red', value: drawVerticalLine,
borderWidth: 1, borderColor: 'red',
label: { borderWidth: 1,
backgroundColor: 'rgba(0,0,0,0)', label: {
fontFamily: "sans-serif", backgroundColor: 'rgba(0,0,0,0)',
fontSize: 12, fontFamily: "sans-serif",
fontColor: "#333", fontSize: 12,
position: "right", fontColor: "#333",
xAdjust: -20, position: "right",
yAdjust: -125, xAdjust: -20,
enabled: true, yAdjust: -125,
content: todayText enabled: true,
} content: todayText
}] }
}; }]
};
}
} }
allCharts[container] = new Chart(ctx, chartOpts); allCharts[container] = new Chart(ctx, chartOpts);
} }