Skip to content

Instantly share code, notes, and snippets.

@VhMuzini
Created February 14, 2019 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VhMuzini/a5f27cc4a7136b8727b248e1ee30ab00 to your computer and use it in GitHub Desktop.
Save VhMuzini/a5f27cc4a7136b8727b248e1ee30ab00 to your computer and use it in GitHub Desktop.
Chart Annotation Sample
import 'chartjs-plugin-annotation';
static chartOptions() {
const options: any = {
responsive: true,
title: {
display: true,
text: ''
},
scales: {
yAxes: [{
type: 'linear',
scaleLabel: {
display: true,
labelString: '',
}
}],
xAxes: [{
scaleLabel: {
display: true,
labelString: 'Past Seven Days of Update'
}
}]
},
annotation: {
annotations: [{
// Horizontal Line
type: 'line',
mode: 'horizontal',
scaleID: 'y-axis-0',
value: 3,
borderColor: 'rgb(40, 167, 69)',
borderWidth: 2,
label: {
enabled: true,
content: 'Y Label'
}
},
{
// Vertical Line
type: 'line',
mode: 'vertical',
scaleID: 'x-axis-0',
value: 7,
borderColor: 'rgb(58, 167, 69)',
borderWidth: 2,
label: {
enabled: true,
content: 'X Label'
}
}
]
}
};
return options;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment