score:0
you can change the long label name to an array, chartjs will split each element into a line , this exemple worked for me :
labels: ['dab', ['park', 'assist'], ['lane', 'assist'], ['smartphone', 'interface'], 'gps', 'led']
but, in this case, when you pass the mouse over the chart, the tooltip shown will seperate each line by a comma, in my case ['park', 'assist'] will be shown on tooltip as "park,assis". to resolve this problem you have to remove the comma by a space in tooltips callback, like this :
tooltips: {
enabled: true,
callbacks: {
title: function(tooltipitem, data) {
return data.labels[tooltipitem.index];
},
label: function(tooltipitem, data) {
let dataval = data.datasets[tooltipitem.datasetindex].data[tooltipitem.index];
let dslabels = data.labels[tooltipitem.index];
// remove the comma
dslabels = dslabels.tostring().replace(",", " ");
return ' ' + dslabels + ' : ' + dataval + '%';
}
}
},
score:1
change label definition to:
labels: [["2016-02-11", "19:59:24"], ["2016-02-11","20:59:24"]]
score:5
according to the official sample repo you should put the single lines into another array:
data: {
labels: [['june', '2015'], 'july', '...', ['january', '2016'], 'february', '...'],
// rest of config
in this case june 2015
and january 2016
would have a new line for the year, the rest of the labels would not be wrapped.
the example is from a line chart, i tested it with a bar chart too, but it should work for all chart types.
tested with version 2.7.2 of chartsjs
Source: stackoverflow.com
Related Query
- change long labels to multiline(wrap) label in ChartJs
- Truncating canvas labels in ChartJS while keeping the full label value in the tooltips
- Chartjs change the specific label color in x axis in callback function
- Chartjs Radar - Change color of end point labels
- How to Change the Label Strike-Through with light gray on a ChartJS Doughnut?
- label too long in yAxis with chartJs
- Change font family of labels in piechart and linechart in chartjs
- Is there any way to change the font color and size of labels in Chartjs 3.0.0
- In ChartJS how do I change the color of a label in the legend?
- ChartJS multiple sub labels for label
- ChartJS have xAxes labels match data source
- VueJS + Chartjs - Chart only renders after code change
- ChartJS with ChartJS DataLabels: Change Color per Dataset for Value Labels
- How to change bar color acording to label value in chartjs
- The title of my ChartJs on the chart is undefined, but I can't change it because my labels use a function: Object.keys(groupMedia)
- ChartJS - change chart type by changing y-axis Label
- Change Chartjs label color on click without losing hover
- ChartJS fails to render one of the lines in cartesian chart following update after change to max Y axis label value
- ChartJS - PieChart's Label too long and hide the PieChart
- ChartJS change monthly labels as time/date
- make chartJS labels clickable and get label details
- Chart Js Change Label orientation on x-Axis for Line Charts
- Chartjs change grid line color
- Chart.js and long labels
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- how to change size of point in ChartJS
- ChartJS - Draw chart with label by month, data by day
- Chart Js change text label orientation on Ox axis
- Make x label horizontal in ChartJS
- Chartjs hide data point labels
More Query from same tag
- error : "Uncaught TypeError: Cannot read property 'length' of null" Chart.js
- Chartjs linechart with only one point - how to center
- Why chart renders after second click - react-chartjs-2
- Chart.js 2.0.0-beta2 disable points on line Charts
- setInterval on my Doughnut.js
- Using Chart.js version 3, How to left justify the y-axis labels on a stacked bar chart?
- How to get Uptime charts for Web Monitoring like Dynatrace?
- Chart.js with JSON data error
- Not able to change chart.js x and y font colors
- Gradient line chart with ChartJS
- Drawing line chart in chart.js with json response
- Angular2 ng2-chart customizations?
- add value to Line chart.js
- Horizontal gradient for every single bar in group chart js
- Chart.js how to resend animation command to a chart?
- ChartJS - PieChart's Label too long and hide the PieChart
- Add some Text Inside of the Tooltip
- Changing style of individual point Chart.js
- Chart JS Re-Animate chart with onclick
- Chartjs extended doughnut with text tooltip issue
- Animate Chart.JS Only Once
- Pushing data from json to Chart.js labels and data
- How to get data from JSON for chart.js, using vue.js
- How can I create a stacked bar chart with Charts.JS that displays relative rather than absolute values?
- Cannot import chart.js-plugins-annotations
- Laravel 5.1 format date array for chart.js data
- Chartjs : data labels getting overlapped in smaller datasets using chartjs-plugin-datalabels
- Chart.js dynamic updates with data from database
- Chart js. How to change font styles for "labels" array?
- chart.js addData breaks function v1.0.2