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
- Chart.js creating multiple Charts in Angular in same Component
- Tell if an line is hidden
- Initialize a Chart.js chart with data from an api
- Chart.js not being displayed inside Jquery Dialog
- dynamically update the scale type of chartjs graph
- Chart.js: Can't get a coordinate for value for x axis unless x axis has the exact same value
- how to format date string for x axis labels in chartjs?
- Is there a way to draw floating rectangle using chart.js
- Not being able to display value from json data into chart js
- chartjs datalabels not showing anything with django template
- How to have solid colored bars in angular-chart bar chart
- Values on Y-axis disappear (hide under labels)
- Attach data to label (Chart.js & Django 3)
- How to change fonts and axis labels for Chart.js image rendering with QuickChart?
- Chart.js is only displaying after f12 is pressed
- Chartjs - how to change the notation of doughnut chart
- Add codeigniter php data to Chart js
- Adding different point style to each column from parsed csv in chart.js
- Chart.js minimal width of Chart with scrollable overflow
- ChartJS Bar Graph Gap
- Input data in german data format combined with ChartsJs
- How to display Tooltip without hovering pie chart with Chart.JS
- Chart.js not to be begin in Y-Axis
- Chart.js: colouring tooltip labels
- Charts.js v2: always show custom (html) tooltips on chart
- How I can use a list of a string array in JavaScript into blade view?
- ChartJs bar chart bar value displaying lower then Y axis value in pdf?
- How to ignores labels in chart.js
- Chartjs - data format for bar chart with multi-level x-axes
- Remove tooltip if has no label