score:1
i faced this issue as well, i managed to fix it like this: this is an example for the chartjs-plugin-annotation
what i forgot was to register the plugin in the beforedraw
event
const chartjsnode = require('chartjs-node');
const chartjsannotation = require('chartjs-plugin-annotation');
var chartnode = new chartjsnode(width, height);
chartnode.on('beforedraw', function (chartjs) {
// register the annotation plugin
chartjs.plugins.register( chartjsannotation );
});
chartnode.drawchart( <your_chartjs_configuration> )
.then( function(){
// save as testimage.png
chartnode.writeimagetofile('image/png', './testimage.png');
});
and your configuration (example):
type: 'line',
data: {
...
},
options: {
...
annotation: {
annotations: [{
value: 100,
type: 'line',
mode: 'horizontal',
scaleid: 'y-axis-0',
bordercolor: '#d2dae2',
borderwidth: 1,
borderdash: [2, 2],
label: {
content: 'value 1'
}
}, {
value: 50
type: 'line',
mode: 'horizontal',
scaleid: 'y-axis-0',
bordercolor: '#d2dae2',
borderwidth: 1,
borderdash: [2, 2],
value: 500,
label: {
content: 'value 2'
}
}]
}
Source: stackoverflow.com
Related Query
- How to properly use the chartjs datalabels plugin
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- How to add ChartJS code in Html2Pdf to view image
- How to import and use a custom Chart.js plugin in Nuxt? (Chartjs-vuejs v2.9.4)
- How to use custom rendering methods of chartJs through ng2-charts angular?
- How to use an Addon with ChartJS on Angular 4
- How to use an Aurelia JSPM plugin with WebPack
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- how to use chartjs graph in a *ngFor loop
- How to use JSON data as chartjs data?
- Chartjs v7.0 with plugin zoom, strange effect when use "drag" mode.
- How to use plugins in chartjs and laravel chart consoletvs/chartsjs
- How to use Utils from Chartjs on Django
- How to use date in x value for Object[] in chartjs dataset, I am getting an error: 'TS2322: Type 'string' is not assignable to type 'number'.'
- How to install plugin for chartjs in javascript
- How to use plugin in chartjs-node?
- How do you get the width of a datalabel from the Chartjs plugin after the chart animates?
- how to use chartJS to show breakdown of selected data
- how can i use inline plugin inner title for chart js?
- chartjs - How to use differente color if value is lower than previous value?
- 'require is not defined' error when attempting to use chartjs in javascript code
- React - how to get array from store before first render and use it as dataset for ChartJS
- How to use GET method to choose the right table to show ChartJS graph?
- How to run Chart.js samples using source code
- How to use ChartJS object in a click event handler?
- How to inject data into chartjs plugin function?
- How do I use ChartJS with a background color in the space between two line charts?
- How do i use chartjs in react project properly?
- how do i use the numbers i key in from a form as the input data for chartjs
- How to use two Y axes in Chart.js v2?
More Query from same tag
- Type error in using chartjs and tc-angular-chartjs
- Pass data to Chart Js Laravel
- Chart not displaying from JSON data
- Return 0 as data for months with no data
- Chart.js fix minimum axes?
- Chart.js multiple dataset issue: hovering over n-th point "hovers" over every dataset's n-th point
- Popup windows for histogram with AngularJS
- Charts.js : How to remove the Vertical Black lines in Bar Chart
- how can I show only 2 numbers on the xAxe in Chartjs having more than two numbers on the chart? (line chart)
- Chart.js v2 charts do not display inside angular 2 (but Chart.js v1 works perfectly)
- Converting Chart.js canvas chart to image using .toDataUrl() results in blank image
- How to add datas to chart js from javascript array itself?
- Using Variable in labels Chart.js of map Array
- Chart js show levels on top. (Bar chart with Stacked group)
- Chart.js only last point
- ChartJS: How to dynamically create data arrays
- Having problems displaying multiple charts on a page
- Chart js. How to change font styles for "labels" array?
- ChartJs showing wrong labels of data (x-axis dates)
- Why is borderColor function in chartjs running multiple times, and how to reduce it?
- Min value of chart (Chart.js)
- Dynamically populate array with Firebase Data Vue.js
- Chart.js - access yAxes properties
- Use chart.js with freemarker tamplates
- chart.js time x-axis - start ticks at specific time
- How to show tooltip on legend item in chart.js
- y axis Formatting with Metric prefix 1000=> 1k Chart.js
- Non numeric for x-axis in scatter chart in CHART.js
- Show values on top of bars in chart.js
- Is it possible to make 3D pie chart using chart.js?