score:2
Accepted answer
Considering you have two arrays (marketing
and amount
) as such :
var marketing = ['2017-08-05', '2017-08-12'];
var amount = [50, 70];
You can create/populate the annotations
array dynamically based on one of those arrays (marketing/amount) to draw multiple vertical lines, like so :
// populate 'annotations' array dynamically based on 'marketing'
var annotations = marketing.map(function(date, index) {
return {
type: 'line',
id: 'vline' + index,
mode: 'vertical',
scaleID: 'x-axis-0',
value: date,
borderColor: 'green',
borderWidth: 1,
label: {
enabled: true,
position: "center",
content: amount[index]
}
}
});
see a working example.
Source: stackoverflow.com
Related Query
- ChartJS / Chartjs-plugin-annotation How to draw multiple vertical lines using an array?
- Can't Draw Horizontal Line on Graph Using ChartJS Annotation Plugin and Primevue Chart
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- How to draw horizontal Lines using chart.js 3.x ? Cannot get it working
- How to draw multiple line on y axis for same x axis in chartjs v2?
- How to draw multiple color bar in a bar chart using chart.js
- How to set vertical lines for new day on x-axis in ChartJS v3.x
- How to draw a range label on x axis using chartJS
- How to draw multiple color bars in a bar chart along a Horizontal Line using chart.js
- Chartjs annotations-plugin: Can I add multiple vertical lines to identically named x-axis labels?
- ChartJs How to display horizontal and vertical lines through the datasets points with their values on axes?
- How to run Chart.js samples using source code
- How to draw multiple lines in chart.js
- How do I draw horizontal bars with a label using either ChartJS or D3?
- How to add vertical line in bar chart using chartJs and ng2-charts?
- how to plot multiple time series in chartjs where each time series has different times
- How to Draw Gantt chart using chart js or other libraries
- ChartJS : How to leave just points without lines
- How can I draw dotted line using chartjs?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- how to show multiple values in point hover using chart.js
- How to properly use the chartjs datalabels plugin
- How to render a vertical line on hover in chartjs
- Draw two plots using chartjs over one another with transparency
- How to draw Horizontal line on Bar Chart Chartjs
- How to work out Chartjs using TypeScript with Chartjs.definitelyTyped from github
- Want to draw data using chartjs in django
- How to use chart.js script to draw multiple pie Charts
- Multiple stacked bar chart using ChartJs
- How to add background color between two lines in yAxis Chartjs
More Query from same tag
- charts.js chart showing old data on hover
- Laravel Chart JS change data with dropdown
- cannot view graph using toArray()
- How to implement chart js using viewbag in mvc razor
- Chart disappears, when pressing the submit button
- Getting data into script tag from route?
- chart.js on animation end callback
- How to set chartJs Doughnut labels on right side?
- chart.js how to force min and max y axis values
- How to access the Chart object in Javascript DOM?
- Html chart does not fit a small Android WebView
- Change font size and font color in Chartjs Angular 5
- How to make chart with chartjs.?
- How to remove percentage calculation on top of bar in ng2-chart bar chart
- Style individual points from one dataset in Chart.js
- Can't get Chart.js to run in a Vue.js component
- Attach data to label (Chart.js & Django 3)
- How to change fonts and axis labels for Chart.js image rendering with QuickChart?
- Hiden Gridline in chart JS
- How do i find area under the graph
- Chartjs 1 to n relationship
- Can you set bar thickness to align with the x-axis scale in ChartJS?
- How to increase space between label and chart area in chart.js
- How can I place single data on the center in Chart.js?
- VueJs and ChartJs - Chart is responsive in width, but not height?
- How to make a interactive legend with chartjs
- chartjs-node-canvas doughnut chart
- I am getting TS2339: Property 'chart' does not exist on type 'Window'?
- Chart point hover error
- Using Variable in labels Chart.js of map Array