-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
New Donut chart and Pie chart #149
base: master
Are you sure you want to change the base?
Conversation
Does it allow to add click handler on sectors? If it is, how do we do? |
Yes it does. var options = {}; // you know what to do with it...
var chart = new Morris.Pie(options);
chart.on('click', function(id, row){
console.log(id, row);
});
chart.on('hover', function(id, row){
console.log(id, row);
}); |
👍 to this! |
👍 |
Tried adding click handler on sectors. It works well. Hope it will be merged with master. |
+1 to this too! |
👍 |
2 similar comments
+1 |
+1 |
+1 |
I agree with this approach, by now the only ways to change stroke color on pie/donut charts that i know are by editing the plugin's source or changing it via Raphael.js inline (i've never tried that last). Maybe a good idea is to set a parameter like |
hi, why haven't you merged this with the master? any issues? is it ready for production? |
Two reasons:
|
I completely understand you, @oesmith. Maybe is time for you to elect one or more fellows to help you maintain the On Tue, Apr 9, 2013 at 5:26 PM, Olly Smith notifications@github.com wrote:
Atenciosamente, |
I do understand your POV. But I think that if you want Morris to be used wider (and I think you want) some functionality should be changed to use the ones users are used to. I think that tooltips should be controlled by CSS (html ones, like in other charts). Displaying the value (and label) as you do right now could be controlled by And more, I think that donut chart should in near future support multiple series, because that's the purpose of displaying data in donut instead of a pie. |
My philosophy for Morris.js is for it to be a simple charting library. It's the one you reach for when you want to do something quick and simple, without sacrificing aesthetics. Features like milti-dimensional donut charts and rich interactivity are beyond that philosophy. I'd very much prefer people to be using more advanced visualisation libraries like D3. |
Usage simplicity (and small amount of code) does not imply the lack of some functionaltiy. But I understand you and won't insist on pushing functionality you object to. Others can always use one of forked repositories (mine, for instance) if they want to. Thanks for the great work you are doing here 👍 |
@tiraeth - How to create a pie chart with your forked repository of morris.js? Can´t find any examples.. |
See |
+1 The hover and click binding would allow for a wide range of customisation, without any added complexity to the current usage. |
Is this merged on master already? |
👍 |
1 similar comment
👍 |
Anything happening? |
if @el is null or @el.length == 0 | ||
throw new Error("Container element not found.") | ||
|
||
if options.data is undefined or options.data.length is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't great since if we're going to create Pie chart with initial options and only then set data using setData() & call redraw() we will get Exception while trying to access @options
object since it wasn't initialized in constructor. I do realise the same code was before that in Donut class.
Coming back to this PR have few questions:
|
As in my previous PR, new version for these two folks. I've also added callbacks for
hover
andclick
events.Currently only one series per donut chart but in future more series will be available to be put there. These charts support 0-valued rows by providing
@options.minSectorAngle
(in degrees) to be used as a minimum value for a sector.Please mind that if
minSectorAngle: 5
then sectors with values0
and3
will have the same angle in the chart.@options.showLabel = (true|false|"hover")
),@options.drawOut
(defaults to5
) which will affect outer (and inner in case of Donut) arc,@options.idKey
) to identify clicked/hovered sectors in callbacks (you also get the whole data row extended withsector
%-value andangle
degree-value),Hint: I am very seriously thinking about getting rid of the
stroke
parameter and handle the spacing between sectors with math instead of path's stroke.PS. Sorry for two commits per PR. Forgot to rebase 😢