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
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

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