score:1
Accepted answer
yLabel
and xLabel
dont exist anymore on the tooltip, they are V2 syntax.
You can just axess the y object in the parsed section to get the y value. Then you can use the afterBody
callback to show the x label like so:
const options = {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderColor: 'pink'
}]
},
options: {
plugins: {
tooltip: {
displayColors: false,
backgroundColor: 'rgba(45,132,180,0.8)',
bodyFontColor: 'rgb(255,255,255)',
callbacks: {
title: () => {
return
},
label: (ttItem) => (`${ttItem.parsed.y} ppm`),
afterBody: (ttItems) => (ttItems[0].label)
}
}
}
}
}
const ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script>
</body>
Source: stackoverflow.com
Related Query
- How can I display the xAxes and yAxes data in the tooltip, Chart JS?
- How can I have different values for the chart and the tooltip in chart.js?
- chart js tooltip how to control the data that show
- Chart js: how can I align the legend and the title
- How can I datalabels and Sum display in the same time on a stacked bar
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- How can I display different values on xAxes than on tooltip Chart.js V3
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- Angular 2: How to pass my API data to graph and Display the Graph with data
- Chart.JS: How can I only display data labels when the bar width is big enough for the text?
- How to set the xAxes min and max values of time cartesian chart in Chart.js
- how can i use chart.js to create a chart that has one time series line and one linear line on it at the same time?
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- Chart.JS: How can I only display data labels when the doughnut size is big enough for the text?
- How to show tooltip value of all data falling on the same axis in chart js?
- ng2-Chart: can we show the tooltip data of pie chart on load?
- How can i display my data in a chart using chart js
- Chart.js How to sum the values in a pie chart and display them in the header
- How can I get my Chart.JS bar chart to stack two data values together on each bar, and print a calculated value on each bar?
- How can I reduce the spacing between my legend and chart proper in my Chart.JS bar chart, and increase it in the graph area?
- How can I display `Null` value data on Y Axis using the Primitive dataset format in Chart.js V3.7.0?
- How can I display the percentage inside the graph and on hover?
- How to start the chart from specific time and offest hour and then show the data on chart from target datetime in chartjs
- How do i have a single Chart.vue component instead of different chart components and then display charts from it by changing id of the API
- How I can add the predict data and the actual data in the same graph with ChartJS?
- How can I process json file and display some data in form of charts in django
- How Can customize chartjs doughnut chart border and tooltip
- How to set the data of chart in angular which is taken from the backend nodejs api that is store in mongodb and showing on the html page
- Chart.js returns a console error and does not display the chart when using variables as data input
- How to adding data in loop and display chart dynamically like in live (chart.js & typescript & angular)?
More Query from same tag
- Is it possible to shorten outer labels on Radar graph using Chart.js, without affecting the other labels?
- Chart.js remove shadow from line chart
- chartjs line graph destroy function is not clearing the old chart instances
- How can i display my data in a chart using chart js
- Laravel passing orders to Chart.js
- ChartJS v2 - Outer arc when hover on a pie/doughnut segment
- How to add dataset legend in chartjs tooltip
- Chart.js: Some sectors not showing if difference is too big
- How to create chart.js vertical bar chat with rounded corners in angular 6?
- How to pass my array of objects into a graph with Chart.js
- Is it possible to produce circular (round) shaped radar chart in Chart.js?
- How to display Json object in chart js consisting of lists created using Django rest framework in angular application
- Chart.js - How does it calculate Y-Axis on bar chart?
- Getting "Uncaught TypeError: Cannot read properties of undefined (reading 'map')" when using Chartjs inside react axios method
- Reopening a "ChartJS" chart in a new window (VS, C#, ChartJS)
- How to add background color for doughnut mid using chart,js
- How to display small numbers in chart js tooltip?
- Chart.js runs in JSFiddle but not local "Chart is not defined"
- Dynamicly update scatter/line chart in Chart.JS with multiple x/y grids
- Chartjs - display radarchart lines from center to corner value
- Why does x axis not increment 'monthly' chart.js. Also, XAxis not taking title
- Is there a way to trigger point hit on an xAxis hover
- Chartjs.org Chart only displaying in one page
- Chart.JS: Stop chart from rescaling when hiding/unhiding a dataset?
- Chartjs xaxes tick min
- Installing chartjs in project without npm, bower or CDN
- Why would a ChartJS chart end up with width 0 and height 0?
- first and last value is not displaying in chart.js used with django
- Chart.js unable to render the chart with data reactjs
- Chartjs working with large and small values