Does Chart.js (documentation) have option for datasets to set name (title) of chart (e.g. Temperature in my City), name of x axis (e.g. Days) and name of y axis (e.g. Temperature). Or I should solve this with css?
var lineChartData = { labels : ["January","February","March","April","May","June","July"], datasets : [ { fillColor : "rgba(220,220,220,0.2)", strokeColor : "rgba(220,220,220,1)", pointColor : "rgba(220,220,220,1)", pointStrokeColor : "#fff", pointHighlightFill : "#fff", pointHighlightStroke : "rgba(220,220,220,1)", data : [data] } ] }
Realy thanks for help.
Click the chart, and then click the Chart Design tab. Click Add Chart Element > Axis Titles, and then choose an axis title option. Type the text in the Axis Title box. To format the title, select the text in the title box, and then on the Home tab, under Font, select the formatting that you want.
The example below would enable a title of 'Custom Chart Title' on the chart that is created. const chart = new Chart(ctx, { type: 'line', data: data, options: { plugins: { title: { display: true, text: 'Custom Chart Title' } } } }); Copied!
In Chart.js version 2.0, it is possible to set labels for axes:
options = { scales: { yAxes: [{ scaleLabel: { display: true, labelString: 'probability' } }] } }
See Labelling documentation for more details.
For Chart.js version 3
options = { scales: { y: [{ title: { display: true, text: 'Your Title' } }] } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With