score:1
take a look at the fiddle - pie chart with chart.js i made the following changes:-
var piechartcanvas = $("#mychart").get(0).getcontext("2d");
var piechart = new chart(piechartcanvas);
piechart.pie(data, options);
score:0
from the example you gave it looks like the syntax has changed too.
it should be
var mypiechart = new chart(ctx).pie(data);
not
var mypiechart = new chart(ctx, {
type: "pie",
data: data,
options: options
});
got that from the example found in the docs -> https://github.com/nnnick/chart.js/blob/master/samples/pie.html
score:0
they also changed the data format in 2.0. if you checkout the sample here. you'll see the data is like this now:
data: {
datasets: [{
data: [
...
],
backgroundcolor: [
...
]
}/* notice you can have more than one dataset, with pie they interlace when you have more than one */],
labels: [
...
]
}
hope that helps.... also i needed to pull the v2.0-dev branch and build it myself to get past one bug that i found in the "released" version, so you may have better luck with that!
Source: stackoverflow.com
Related Query
- Piechart doesn't show up in Canvas
- Show base64 image next to canvas with charts.js
- 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
- Chart.js canvas rendered by ng-repeat does not show charts
- How to run Chart.js samples using source code
- How to clear a chart from a canvas so that hover events cannot be triggered?
- Chart.js canvas resize
- Charts.js graph not scaling to canvas size
- Chart.js Show labels on Pie chart
- Show values on top of bars in chart.js
- ChartJS: datalabels: show percentage value in Pie piece
- Converting Chart.js canvas chart to image using .toDataUrl() results in blank image
- How to add labels into Chart.js canvas plugin?
- ChartJS: How to get labels, legend, title to show up?
- Why is chart.js canvas not respecting the padding of the container element?
- Truncating canvas labels in ChartJS while keeping the full label value in the tooltips
- chart.js: Show labels outside pie chart
- Resize chart.js canvas for printing
- Chart.js how to show cursor pointer for labels & legends in line chart
- Canvas static height Chartjs
- ChartJS canvas not displaying rgba colors in IE, Safari and Firefox
- Chart.js padding canvas
- chartjs tooltip is cut off when out of canvas
- Show bar with zero value in ChartJs v2
- Chart.js ignoring canvas height & width
- In Chart.js I want to show dotted gridLines like in below image
- Chart.js: only show labels on x-axis for data points
- show label in tooltip but not in x axis for chartjs line chart
- chartjs show dot point on hover over line chart
- ChartJS Line Graph - Multiple Lines, Show one Value on Tooltip
More Query from same tag
- Apply/Register conflicting plugins to different charts
- How do you disable tooltips in ember-cli-chart?
- how to combine to array for chartjs width php
- Lograthmic yaxsis setting not working in chartjs
- ChartJS using multiple Y axes
- Custom dataset object not setting chart.js bar chart colors in Angular 6
- react-chartjs integration error. Cannot read property 'xLabels' of undefined
- How to add space between two scales in chart-js?
- Chart.js axes always show zero
- Strange "padding" at chart area after updating chart.js (2.8.0 -> 3.4.1)
- Line chart with large number of labels on X axis
- Datalabels plugin throws error when using scriptable option
- Javascript not showing up total value in middle of Oracle APEX Donut chart
- part 2 - how to group duplicate labels in order to create a label without duplicates in chart.js
- Chartjs bar order adjustment after bar chart is drawn
- angular-chart.js : how to show numbers in each bar of stacked bar chart
- after div display set to block nothing shows
- ChartJS: create linear x-axis on bar chart
- Javascript and Chart.js not taking user input assuming it is a variable scope issue
- How to compare input text with database value in Spring Boot?
- How to make a prefilled doughnut in chart.js?
- ChartsJS Legend not showing in Angular11
- Aligning zero on y axis to the labels on x axis of line chart in chartjs
- ChartJS Scatter plot with JSON list variable not working
- chartjs loading data from ajax doesn't work fine
- Is there anyway add 2 or more chart with foreach loop
- Chartjs pie chart not showing from dynamic data
- Chartjs change grid line color
- Create an interactive custom tooltip for chartjs
- Can't pass array to chart.js which got its data from @Input