score:4
Accepted answer
the update()
handles adding data too. just push your new data / labels into the config object that you passed when creating the chart and then call update()
for instance,
var config = {
type: 'line',
data: {
labels: ["january", "february", "march", "april", "may", "june", "july"],
datasets: [{
label: "my first dataset",
data: [65, 0, 80, 81, 56, 85, 40],
fill: false
}]
}
};
var ctx = document.getelementbyid("mychart").getcontext("2d");
var mychart = new chart(ctx, config);
settimeout(function(){
config.data.labels.push('test');
config.data.datasets[0].data.push(3);
mychart.update();
}, 1000);
fiddle - http://jsfiddle.net/zpnx8ppb/
Source: stackoverflow.com
Related Query
- addData() dropped from latest chart.js 2.1.3 - whats up?
- getting additional value fields from data source for dx.chartjs doughnut 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
- Get Chart js object from selector
- How to add datas to chart js from javascript array itself?
- 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 create a gradient fill line chart in latest Chart JS version (3.3.2)?
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- (Vue, ChartJS) Create gradient background for chart from child component canvas context
- In chart.js, Is it possible to hide x-axis label/text of bar chart if accessing from mobile?
- impossible to remove scale from radar chart (chart.js)
- How can I trigger the hover mode from outside the chart with charts.js 2?
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
- Can't size doughnut chart from chart.js
- Using data from API with Chart JS
- Lift the bar up from the bottom in bar type chart
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Stacked bar chart starting from 0 - ChartJS React
- Chart not displaying from JSON data
- How to remove border from stacked column chart in Chartkick - Chart.js
- How to create chartjs chart with data from database C#
- Draw a horizontal bar chart from right to left
- Redraw Chart.js Chart with Json_encoded array from ajax request
- chart.js add second line in a Line chart that starts from end of first line
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
More Query from same tag
- How to change line segment color based on label value in chart.js?
- Chart.js don't work when I open my app as a stand alone app in Chrome
- Horizontal Stacked Bar with Gaps
- Chart.js chart not displaying until I open the browser's console
- Can you change legend style for bar datasets with chart.js?
- How to have mutiple charts in a single page using Chart.js?
- Can't bind to 'chartType' since it isn't a known property of 'canvas' with angular12
- charts js grid line not removing
- Changing the background of a ChartJS on node js
- How to feed hour and minute data into chartJS
- Why is this bar chart using chart.js not rendering in react.js?
- How to fix bar width in chartjs?
- change long labels to multiline(wrap) label in ChartJs
- How to hide the points in a combined Line- and BarChart drawn by Chart.js V2.0
- How do I force Chart.js axes min and max with react-chartjs-2?
- vue-chartjs remove top rectangle (datasets label)
- Limit numbers of labels on Chart.js in "smaller display only"
- Django - update dictionary with missing date values, set to 0
- Chartjs v3 tooltip label not showing tooltip label color on custom calbacks
- Chartjs tooltip out of page
- how to fix this error Array to string conversion in laravel and chartjs?
- Vertical Bar Chart not displaying Correctly
- json_encode returns "
- chart.js How to show last column’s value on y axios?
- javascript chart library for every minutes data
- How to pass data for stacked chart in vue-chartkick
- Chart.js bumpy line
- Add Text to Doughnut Chart - ChartJS
- chartjs plugin datalabels does not show value on charts
- ChartJs - Footer color dynamically