Skip to content
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

Closed
FeiTeng-Alfred opened this issue Nov 16, 2015 · 4 comments
Closed

Original usage of pie failed #1659

FeiTeng-Alfred opened this issue Nov 16, 2015 · 4 comments

Comments

@FeiTeng-Alfred
Copy link

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?

@etimberg
Copy link
Member

@FeiTeng-Alfred v2 uses a different syntax to instantiate charts. See https://github.com/nnnick/Chart.js/blob/v2.0-dev/samples/pie.html

@FeiTeng-Alfred
Copy link
Author

@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

@etimberg
Copy link
Member

@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.

@etimberg
Copy link
Member

@FeiTeng-Alfred I fixed the pie legend generation in #1667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants