score:2
i'm using v2.0.0 from the dev branch (the file header reads 2.0.0-alpha, and the file i'm looking at is https://github.com/nnnick/chart.js/blob/f3eb6f4a433b4f34a582842dcf7b42f710861a7d/chart.js)
you need to make a few changes to get your fiddle to work
make the chart type an option
i think v2.0 has only one constructor for all chart types. so
chartdata = new chart(ctx).line({
should be
chartdata = new chart(ctx, {
type: "line",
add a type for the 2nd y-axis
scaletype: "linear"
to
type: "linear",
type is the property name. it doesn't cause any problem for the first y axis since it's optional there (your scaletype: "linear"
on the first instance doesn't actually do anything and you can drop it)
remove the window.onload
your fiddle is already set to execute onload
change the method signature
as far as i could see from the code, the method signature has changed for adddata. it is now as follows (from the code) - note that this could change anytime
// add data to the given dataset
// @param data: the data to add
// @param {number} datasetindex : the index of the dataset to add to
// @param {number} index : the index of the data
adddata: function adddata(data, datasetindex, index)
so a better version of your setinterval would be
setinterval(function () {
var latestlabel = chartlabel[6];
chartdata.adddata(12, 0, latestlabel);
chartdata.adddata(5, 1, latestlabel);
chartdata.removedata(0, 0);
chartdata.removedata(1, 0);
}, 7000);
Source: stackoverflow.com
Related Query
- what is wrong with my code ? java script chart position
- How to print a chart rendered by code
- Chart JS prepend labels to x-axis with addData
- VueJS + Chartjs - Chart only renders after code change
- How do I destroy/update Chart Data in this chart.js code example?
- getting additional value fields from data source for dx.chartjs doughnut chart
- 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
- Getting the HTML code of a chart created by chart.js
- How to run Chart.js samples using source code
- how to not repeat code while creating multiple charts in chart js
- Set height of chart in Chart.js
- Dynamically update values of a chartjs chart
- How to add text inside the doughnut chart using Chart.js?
- How to clear a chart from a canvas so that hover events cannot be triggered?
- In Chart.js set chart title, name of x axis and y axis?
- Limit labels number on Chart.js line chart
- Chart.js - How to set a line chart dataset as disabled on load
- chart js 2 how to set bar width
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- Chartjs Bar Chart showing old data when hovering
- Chart.js Show labels on Pie chart
- Chart Js Change Label orientation on x-Axis for Line Charts
- Chart area background color chartjs
- Chart.js - Increase spacing between legend and chart
- Converting Chart.js canvas chart to image using .toDataUrl() results in blank image
- Draw horizontal line on chart in chart.js on v2
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- Remove the vertical line in the chart js line chart
- Chart.js: Bar Chart Click Events
- Chartjs v2.0: stacked bar chart
More Query from same tag
- Angular chart.js onClick is not working - how to get all elements of a bar when it is clicked on
- ChartJS date reformatting for use?
- Chart.js Show labels on Pie chart
- PrimeNg bar chart how do I hide the bar labels?
- JQuery Datatables overlapped when using column filtering
- Chart.js v2 hide dataset labels
- Chart Piechart in only show percentage on hover but it shows data and label with percentage both i just want to show percentage only percentage
- how can I make selected data is highlighted on chart js?
- How to load data values from cookie into Chart.js
- Gradient effect with Chart.js and Angular
- how can i use inline plugin inner title for chart js?
- How to draw the X-axis (line at Y = 0) in Chart.js?
- Show percentage of category relative to stacked bar in Chart.js
- chart.js not working in browser with django. no error for template and static folder setting
- Is it possible to set up 0 as a minimum number for bar chart? react-chart.js-2
- Remove data text from Chart.js on hover
- How to update ChartJS in a long polling & stop animation stuttering?
- Prevent scroll when calling update()
- How to trigger ChartJS legend onClick with out interrupting its normal working
- Chart.JS spacing and padding
- How I connect chart.js to database in ASP.NET web form?
- Creating a heart rate monitor
- Problem creating chart out of GET request with Angular
- How to download chart js image as bmp
- chart js stripline? like one from canvas
- Calculate the average distance between two data sets of X and Y (in JS)
- How to apply each color to each dataset
- angular-chart.js bar chart with 100% opacity color
- Meteor / React.js / Chart.js issue
- Chartjs not showing up in Foundation5 Tabs