score:3
Accepted answer
i am assuming you are talking about the tooltip's label. in that case, you can set tooltips mode to index
in your chart's options config, like so :
options: {
tooltips: {
mode: 'index'
},
...
ᴡᴏʀᴋɪɴɢ ᴇxᴀᴍᴘʟᴇ ⧩
var ctx = document.getelementbyid('price-history').getcontext('2d');
ctx.height = 150;
var chart = new chart(ctx, {
type: 'line',
data: {
labels: ['jan', 'feb', 'mar', 'apr', 'may'], //<?= json_encode($pricechangedata['labels']); ?>,
datasets: [{
label: 'minimali kaina',
backgroundcolor: 'rgb(64, 127, 178)',
bordercolor: 'rgb(64, 127, 178)',
borderwidth: 1,
data: [3, 1, 4, 2, 5], //<?= json_encode($pricechangedata['line']['price_min']); ?>,
fill: false
}, {
label: 'vidutinė kaina',
backgroundcolor: '#686868',
bordercolor: '#686868',
borderwidth: 1,
data: [2, 4, 1, 5, 3], //<?= json_encode($pricechangedata['line']['price_avg']); ?>,
fill: false
}],
},
options: {
responsive: true,
tooltips: {
mode: 'index'
},
layout: {
padding: {
left: 20,
right: 15
}
},
scales: {
xaxes: [{
display: true,
scalelabel: {
display: false,
labelstring: 'data'
}
}],
yaxes: [{
display: true,
stacked: false,
scalelabel: {
display: false,
labelstring: 'kaina'
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.7.0/chart.min.js"></script>
<canvas id="price-history"></canvas>
Source: stackoverflow.com
Related Query
- Is it possible to show labels for all lines?
- Chart.js - Hover labels to display data for all data points on x-axis
- Chart.js how to show cursor pointer for labels & legends in line chart
- Chart.js: only show labels on x-axis for data points
- ChartJS: Show all labels of a mixed chart in the tooltip
- Chartjs: Is it possible to hide the data labels on the axis but show up on the graph on hover?
- In Chart.js >3.0, on axis of type time, how to show labels and ticks only for existing data points (make labels reflect data)?
- Setting Common labels and background color common for all the charts in ChartJs
- How to show scale labels and set min/max for yAxes?
- How remove duplicates xAxis labels and show all values on chart
- How to show tick marks and labels with grid line for the specific one on the X axis with Chart.js?
- ChartJS: Show all tooltips with Total for Multi Pie chart
- It is possible to always show all tooltip in Chartjs 3.1
- How to create datasets for all labels for stacked bar in chart.js?
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- Chart.js Show labels on Pie chart
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- Chart.js Line-Chart with different Labels for each Dataset
- chart.js: Show labels outside pie chart
- show label in tooltip but not in x axis for chartjs line chart
- Select All and Unselect Option for chart.js
- Using Chart.js - The X axis labels are not all showing
- Chart.js - Line charts with different colors for each border lines
- Chart JS show multiple data points for the same label
- Pie chart.js - show all 3 segment borders
- How to display data labels outside in pie chart with lines in ionic
- How to show Y axis ticks for every point in the graph
- Chartjs - show elements in all datasets on hover using bar chart
- Show only nth tick LINE on x-axis for Chart.js diagram
- Is it possible to set up 0 as a minimum number for bar chart? react-chart.js-2
More Query from same tag
- How to add comma in this chart js
- How to add space between two scales in chart-js?
- Cant change labels in Chart.js 2.0 Beta
- How to change hours format to percentage in a Chart.js pie chart
- How do I make many ChartJS charts on the same page to have the same height and also even column width?
- Render pie chart datasets out of 100% -- Chart.JS
- Creating mathematical charts using chart.js jQuery
- How to use output of JSON.parse() as a input of HTML charts' data field?
- ERROR TypeError: Cannot read properties of undefined (reading 'skip') Typescript/Api
- How to put 2 labels and distinct tooltips from two bars
- How to Sum values from different objects in Django?
- Chart.js - cannot fetch result from MySQL via PHP
- how to change color of bar if its goes above avg score in mixed graph chart.js
- how to write labels along with data on top and bottom of each stack in bar chart
- Add space between point of the chart and of the border chart in react-chartjs-2
- Give '%' on Bar Chart Datalabel Chartjs
- How to move a chart.js to the center
- Problem in making chart with Chart.js in wix?
- Chart.js how to remove final label on chart
- React chartsJS streaming live data
- Get access to the chart.js component instance in React
- How to hide a portion of chart or a div in Angular?
- chart.js plotting timeseries
- Calling data from search bar to chart.js graph in Angular
- Chart.js not installing with NPM
- chartJS pie chart not updating after axios GET
- Unique identifier in Chartjs Bar segments?
- Chart.js draw y-axis only up to point
- Chart JS - single lines (points) tooltips
- how to minimize x axis labels to day hours in chart js