score:0
Accepted answer
to implement custom label there is a chartjs plugin called datalabels which can be imported using cdn
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.7.0"></script>
or using npm
npm i chartjs-plugin-datalabels
refer the below code to which implement custom date as label
let x = [],
y = [];
data.foreach(z => {
let date = new date(z.datet)
x.push(date.tolocaledatestring());
});
var mylinechart = new chart(ctx, {
plugins: [chartdatalabels],
type: "bar",
data: {
labels: x,
datasets: [
{
data: y,
backgroundcolor: [
"rgba(255, 99, 132, 0.2)",
"rgba(54, 162, 235, 0.2)",
"rgba(255, 206, 86, 0.2)",
"rgba(75, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(255, 159, 64, 0.2)",
"rgba(211, 84, 0,0.8)"
]
}
]
},
options: options
});
}
};
````
Source: stackoverflow.com
Related Query
- Using Variable in labels Chart.js of map Array
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- Display a limited number of labels only on X-Axis of Line Chart using Chart.js
- How to display the labels in doughnut chart using ng2 charts?
- Show labels on each sector to polar chart using angular js chart
- Display labels on bar chart using Chart.js
- How to map json array to two different array for chart
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- Rendering Chart.js Bubble Chart Using Array Data
- Labels (category type) on left and right of bar chart using chart.js?
- Custom label from using separate array in Chart JS
- Update the chart data from an array stored in a variable on button click
- Displaying labels on a Doughnut Chart using Chart.js
- Chart, X and Y-Axis labels are blurred in horizontal bar chart using chart.js
- Time chart labels with some X axis labels using Chart js v3
- Generate bar chart using chart.js and associative array
- 【React chart.js】How to add multiple data to Radar chart using map function
- How to show bar chart labels clearly using ChartJS?
- Create a pie chart using an array from a data table in chart.js
- Show the latest labels in a bar chart with React.js using react-chartjs
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Pass custom labels as an array to Chart JS Tool tip
- How can I build some chart with Chart.js and ng2-charts using an array of revenus & budgets per month date as Data source?
- How to run Chart.js samples using source code
- Using associative PHP array in JS to later on use in chart generated via chart.js
- Chart JS is using 1,2,3 as y values for my points for the second dataset instead of their passed in labels
- How to populate a charts.js pie chart using json array
- How to add text inside the doughnut chart using Chart.js?
- Limit labels number on Chart.js line chart
- Chart.js Show labels on Pie chart
More Query from same tag
- How to plot an equation using ChartJS?
- ChartJS - Size of the point doesn't change
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Chart.js - How do I dynamically change bar's stack
- How to shorten Chart.js label
- angular-chart.js, how to change colours labels
- ChartJS - zIndex value for points/tooltips?
- Why does the horizontal bar size jump when resizing the chart?
- Chart.js doughnut animate/draw clockwise
- How can I assign dynamic data from service via subscribe to doughnut chart in angular?
- chartjs chart.update() function not rendering lines in foreground
- Chart.js - draw horizontal line based on a certain y-value
- How to load data values from cookie into Chart.js
- ChartJS : Hook before values are given to doughnut (absolute value in chart and real values in the tooltips)
- I want to use an object to help create a chart with Chartjs
- Chartjs and dynamic data arrays
- ChartJS version 3 how to add percentage to pie chart tooltip
- Charts.js not using the right colors
- Angular Chart.js - Remove Moment.js as Dependency / Reduce Bundle Size
- Equal distance grouped bar chart irrespective of scale - chart.js
- how to display chart.js legend with different bar color
- Changing default values for Chart JS
- Laravel query builder for Charts.js
- Trying to display different types of charts using select/option tag
- Chart.js - How to push a collection of array into dataset
- Update chart axis labels after hover - chart.js
- Where can I download a certain version of d3.js for angular?
- Chart JS no animation line chart
- chartjs resizing very quickly (flickering) on mouseover
- Hiding the ticks on the x-axes clips the chart (Chart.JS)