score:0
Accepted answer
data is an array of objects. you can access the emp_id in following manner using backtick:
labels: `<%= data[0].emp_id %>`, `<%= data[1].emp_id %>`, ... , `<%= data[n].emp_id %>`
you can also push the emp_ids into another array and then use that array as labels.
var data = json.parse(`<%- json.stringify(data) %>`);
var labelsdata = [];
for(var i = 0; i < data.length; i++){
labelsdata.push(data[i].emp_id);
}
let pchart = new chart(mychart, {
type:'bar',
data:{
labels: labelsdata,
datasets:[{
label:'p',
data:[123,234,533,232]
}]
}
})
Source: stackoverflow.com
Related Query
- Pass objects from javascript to Chart.JS through EJS
- How pass a variable from code behind to javascript
- How to pass Arrays from backing bean to JavaScript to draw a chart using Chart.js in an Ajax call
- How to add datas to chart js from javascript array itself?
- Calling external Chartjs chart from a javascript file into HTML in Flask
- Passing an Array from a Flask view to the javascript code of another view
- Pass Data From Node/Express to Front-End Javascript
- How to send data from struts2 to a javascript function to draw a chart
- How to remove all gridlines and ticks all lines in lines chart in javascript taken from cdn)
- How to stop displaying the data values from different data objects on Chart JS 2.x?
- how to insert dynamic data from sql into chartjs stacked bar chart javascript
- How to pass a chart.js chart data object in json from a controller in asp.net mvc
- How to create an array of objects dynamically in javascript for a pie chart
- getting additional value fields from data source for dx.chartjs doughnut chart
- unable to pass data from views to js file having chart js codes, shows unexpected syntax error
- How to filter Chart JavaScript Dashboard by Year through dropdown after the MySQL count query?
- C# MVC5 JavaScript Chart.js Pie Chart with Realtime Updating from SQL Server Database without Refreshing
- syntax to loop through docs send from express router and use it to plot chart js
- angular Chart data-pushing from another javascript
- How to get a value from function javascript and print it to the chart
- How to clear a chart from a canvas so that hover events cannot be triggered?
- Chartjs random colors for each part of pie chart with data dynamically from database
- How to prevent first/last bars from being cut off in a chart with time scale
- Chart.js Bar Chart - how to chart bars from 0
- Chart from chart.js to pdf
- Dynamically update the options of a chart in chartjs using Javascript
- Get Chart js object from selector
- Adding Chart.js line chart to Jinja2/Flask html page from JS file
- How can I remove extra whitespace from the bottom of a line chart in chart.js?
- How to pass model object to javascript function in asp.net Core
More Query from same tag
- How to set global/specific properies when updating line-chart using Chart.js?
- Chart does not display on webpage in Django app (with Chart.js)
- how to fix this error Array to string conversion in laravel and chartjs?
- Stacked horizontal chart. How to trigger individual hover in the stacked element?
- Set max value for each label with Chart.js
- chartjs - multi axis line chart - cannot read property 'min' of undefined
- Update Chart.js plugin
- Chart.js - Add gradient to bar chart
- Annotation events not update the chart
- chartjs table each making series not proceeding to next tr
- syntax to loop through docs send from express router and use it to plot chart js
- Is there any way to change the font size of labels in bar chart in Chart.js v3?
- Chart.js Radar background color of background
- Reactjs- Bar Graph-chartjs- Data not coming in individual blocks
- Chart.js drawing line between two points
- How to make a chart with a string values instead of data?
- Hide min and max values from y Axis in Chart.js
- Chart.js 3.3.0 - Draw text on top of chart
- Chart.js - Toggle visibility of charts
- how to highlight bar in ChartJS with onkeyup Input
- Chart.js how to change width of color
- Checkboxes unchecked after cart.js end of update animation
- Chartjs removing labels and begin number
- How to update ChartJS in a long polling & stop animation stuttering?
- Complex Javascript variables containing the values of other assigned variables?
- chartjs angular update order
- How to have custom colors in ng2-charts and chart.js according to data?
- how to display name on multi series pie chart in chartjs
- chart.js break line in a label with a tooltip callback
- Using vue-charts.js, I cannot get hoverOffset to work with doughnut