score:2
Accepted answer
use this
y=Array.from(Array(12)).fill(0);
content.map((item,i) =>{y[parseInt(item.month)-1]=parseInt(item.donation_amount)});
.
output example .
content = [{
"donation_amount": "10",
"avg_donation_amount": 10.0,
"transaction_count": 1,
"month": 2
},
{
"donation_amount": "60",
"avg_donation_amount": 60.0,
"transaction_count": 1,
"month": 3
},
{
"donation_amount": "1556",
"avg_donation_amount": 97.00,
"transaction_count": 3,
"month": 4
}
];
y = Array.from(Array(12)).fill(0);
content.map((item, i) => {
y[parseInt(item.month) - 1] = parseInt(item.donation_amount)
});
console.log(y);
Source: stackoverflow.com
Related Query
- react chart js skip zero value month
- Chart.js remove zero value sector in pie chart
- Want to show small part of js Bar Chart when value is zero
- getting additional value fields from data source for dx.chartjs doughnut chart
- Chart js bar with the highest value is a different color among the rest - React
- Chartjs bar chart ranges y-axis -1 to +1 if bars value zero
- Show bar with zero value in ChartJs v2
- How to display value of only one datapoint in line chart
- get yLabel value onclick chart js
- Obtain max value of y axis of line chart rendered with Chart.js
- Can't get bar chart colors in Chart js working in React Js
- Chart js data to start at zero
- Chart.js Bar graph will not start at zero as minimum value
- Remove the label and show only value in tooltips of a bar chart
- How to create single value Doughnut or Pie chart using Chart.js?
- Map event position to y axis value in chartjs line chart
- Drawing line chart in chart.js placing dots only when value changes
- React ChartJS 2 : Get data on clicking the chart
- Chart.js: Minimum value for x-axis at horizontal stacked bar chart
- chart.js bar chart color change based on value
- How to hide zero data value from chartjs?
- Chart JS display Data Value on the top of the Bar
- Time Series Line chart js in react not working
- How to remove bars for those bars with zero value in Chartjs bar chart?
- Stacked bar chart starting from 0 - ChartJS React
- Angular chart how to show the legend data value by default along with legend name
- React chart : prevent chart's canvas scaling with height and width
- How to hide value in Chart JS bar
- How to access or get value of specific graph on chart plot by click event?
- Chart.js xaxis formatter changes the value shown in the chart
More Query from same tag
- ChartJS in React throws 'too may re-renders'
- How can I filter these data per month?
- ChartJS Horizontal bars barely visible with 50 records on the Y axis
- How to add datas to chart js from javascript array itself?
- how to hide 0 value on Yaxis in Chart.js with negative values
- Label issue in doughnut chart using chartjs
- How to append text or symbol to tooltip of chart.js
- Chart.js Radial axes: is it possible to use multiple axes on radar chart?
- Passing Global Options to line Chart in 2.1.6/Chart.js
- Chart.js 2.0 doughnut tooltip percentages
- Chart.js Date and Time Bar Chart Not Rendering - Line Works Though
- Configuring ChartJS from VB.NET
- Chart only prints out first value using jquery ajax php
- Chartjs linechart with only one point - how to center
- Order the Time Units on Y-axis + Chart Js
- Chart.js Cannot read property 'apply' of undefined
- Canvas won't appear in html
- Why does the horizontal bar size jump when resizing the chart?
- Tooltip background color gets faded angular-chart.js
- ChartJS remove the legends at the top of the chart
- chart.js tooltip position, tooltip not displayed
- Chart from Database
- Chart.js remove gridline
- How to plot a single value with line in line chart graph using charts.js?
- Ionic2: Use chartjs inside ion-segment
- How to pass values to a chart (chart.js / morris.js)
- Installing chartjs in project without npm, bower or CDN
- ChartJs Force scatter plot to be square shaped
- Border radius for the bar chart in ChartJS
- animation of a graph of an equation javascript