score:1
Accepted answer
datasets
is an array so it would be dataset[0].data.push
rather than dataset.data [0] .push
but your foreach
is looping through each dataset so you can just check if its the dataset you want to update:
function onrefresh(chart) {
for( var i=0; i<set.label.length; i++) {
chart.config.data.datasets.foreach(function(dataset) {
if (dataset.label === 'a') {
// push the data to update a here
dataset.data.push({
x: date.now(),
y: set.lebel[set.label.length-1]
})
}
// do the same for b
});
}
}
Source: stackoverflow.com
Related Query
- How to display multiple graphs in real time with chartjs
- How to display a progress over time in one horizontally stacked bar with chartjs
- how to plot multiple time series in chartjs where each time series has different times
- ChartJS - how to display line chart with single element as a line? (not as a dot)
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- How can I load multiple Chartjs charts with different data on the same page?
- How to display chart using Chartjs with JSON data in Laravel
- how to display multiple sum with chart js and laravel?
- How to take a set of Date objects and display the frequency based on time of day using ChartJS
- How do I display two datasets on a single chart with chartjs
- Chartjs display multiple info with different units in label
- How can I update my ChartJS in real time (It's works only when I zoom-in and zoom-out)
- ChartJS Tooltips with time axis and multiple datasets
- Beginner in JS,Stuck with ChartJS and multiple filters and ways to display
- ChartJs How to display horizontal and vertical lines through the datasets points with their values on axes?
- How to implement doughnut ChartJS with CodeIgniter 3 and display data from database
- How to prevent first/last bars from being cut off in a chart with time scale
- Display line chart with connected dots using chartJS
- Chartjs linechart with only one point - how to center
- How to fix chart Legends width-height with overflow scroll in ChartJS
- ChartJS - Donut charts with multiple rings
- How to display Line Chart dataset point labels with Chart.js?
- How to display inline values in a stacked bar chart with Chart.js?
- ChartJS with AngularJS - Canvas won't display anything
- How to display data labels outside in pie chart with lines in ionic
- Chart.js - How to display title in multiple lines?
- Horizontal bar with multiple sections in ChartJs
- ChartJs line chart - display permanent icon above some data points with text on hover
- How to customize Title position with ChartJS
- how to get React chartjs to resize back down with window
More Query from same tag
- Cant change labels in Chart.js 2.0 Beta
- Truncating canvas labels in ChartJS while keeping the full label value in the tooltips
- Chart.js: bar chart first bar and last bar not displaying in full
- Chart.js bar thickness
- Chartjs not giving 'xLabel' properly on tooltip
- Performance issue, what causes it?
- Display ellipsis for null or empty values in the bar chart using Chart.js
- react chart js, title is not displayed
- Horizontal stacked angular bar charts
- How to See Only the Image of Chart
- How to group smaller Pie Chart slices together to Improve Readability in chartjs
- I cant get Legend to work for my chartjs donut chart
- How to get the X position at a specified chart item index?
- Can't resize react-chartjs-2 doughnut chart
- Split assoc array by keys
- how to plot multiple time series in chartjs where each time series has different times
- Chart.js and Firebase Ionic App Angular 4
- Is it possible to use mouseenter and mouseleave event in chart js?
- Revert tooltip order
- How to disable Chart JS tooltip when there is no value?
- react-chartjs-2 Line Chart not updating with State
- Draw chart.js created by ckeditor plugin
- Chart.JS full-width, responsive doughnut chart with Bootstrap
- ng2-charts - Angular 4 working example
- Chartjs 2.7.3: Set Y data at the correct X position axis
- Why does putting two data sets with a Time Cartesian axis in Chart.js cause two Y axis tick sets?
- Chart.js responsive pie chart
- Chart.js - How to create an auto-scaling line diagram for a big amount of data happenning over time
- How do I implement the 'autoskip' feature in chartjs?
- charts.js chart showing old data on hover