-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Original usage of pie failed #1659
Comments
@FeiTeng-Alfred v2 uses a different syntax to instantiate charts. See https://github.com/nnnick/Chart.js/blob/v2.0-dev/samples/pie.html |
@etimberg Can you give a example how to use generateLegend() in the new version? I keep get error on that. Looks like when we use this function on pie, it won't generate legend correctly. By the way, do we have fix for this issue #592 on v1? As the v2 change a lot syntax, I think I will keep using v1. But I need fix this error. Thanks |
@FeiTeng-Alfred There seems to be a bug in the legend generation for v2 pie charts. I merged #1092 in master which may fix #592. You could also try porting #1470 to v1. |
@FeiTeng-Alfred I fixed the pie legend generation in #1667 |
I update my Chart.js script from 1.0.2 to 2.0 beta, the original usage failed. I got following error:
Uncaught TypeError: (intermediate value).Pie is not a function(…)
Here is how I use:
pieChartHolder = $placeHolder.find('#pie-chart-area')[0].getContext('2d');
myPie = new Chart(pieChartHolder).Pie(pieData, {
showTooltips: true,
responsive: true,
animationEasing: 'easeOutQuart',
segmentStrokeColor: '#f9f9f9',
customTooltips: function (tooltip) {
if (!tooltip) {
return;
}
$tooltipEl = $placeHolder.find('.pie-tooltip');
$tooltipEl.removeClass('above below hide');
$tooltipEl.addClass(tooltip.yAlign);
// split out the label and value and make your own tooltip here
partsOfToolTipText = tooltip.text.split(':');
$tooltipEl.html('%s
%s'.format(partsOfToolTipText[0], partsOfToolTipText[1] + '%'));
$tooltipEl.css({
opacity: 1,
left: tooltip.chart.canvas.offsetLeft + tooltip.x + 'px',
top: tooltip.chart.canvas.offsetTop + tooltip.y + 'px',
fontFamily: tooltip.fontFamily,
fontSize: tooltip.fontSize,
fontStyle: tooltip.fontStyle
});
}
});
Any ideas?
The text was updated successfully, but these errors were encountered: