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

Ability to set selected section #79

Closed
onlymejosh opened this issue Sep 26, 2012 · 7 comments
Closed

Ability to set selected section #79

onlymejosh opened this issue Sep 26, 2012 · 7 comments

Comments

@onlymejosh
Copy link

Is it possible to set the selected area of a donut?

Use Case:

{ label: 'Total', value: total },
{ label: 'Remaining', value: remaining }

I want to select remaining if it is larger than total

@oesmith
Copy link
Contributor

oesmith commented Sep 26, 2012

Grab the latest master, then calling select(n) on the object that Morris.Donut(...) returns.

I've just added some code that should do what you need.

@onlymejosh
Copy link
Author

Hey OIly that was quick!

Its broken somehow though. When I hover over a segment I get

TypeError: 'undefined' is not an object (evaluating 'segment.select')

It looks like when it loads it passes an id to select but on hover it passes the DonutSegment

@oesmith
Copy link
Contributor

oesmith commented Sep 27, 2012

Whoops - my fault for coding too late at night! :)

Try again now - should be fixed.

@onlymejosh
Copy link
Author

Brilliant all working now thanks!

@apudiu
Copy link

apudiu commented Sep 29, 2017

I'm so sorry for asking silly questions, but I'm new to this chart. so if anyone kind enough to help me:

below is my code:

Morris.Donut({
                element: 'donut-chart',
                data: [{
                    label: "Added",
                    value: 30
                }, {
                    label: "Sold",
                    value: 12
                }],
				    colors: ['#414e63', '#e96562'],
                resize: true
            });

every time it initially selects 'Added' value, I've tried flipping position with 'Sold' but no luck.
I think it automatically selects the highest value,

how can I select my desired label? I don't want to select the lowest value coz there will be more items.
so if there's something like select: 'Sold'

Then please let me know.

I'm asking this question coz I didn't understood what to do with

Grab the latest master, then calling select(n) on the object that Morris.Donut(...) returns

Thank you

@robbieyannor13
Copy link

I'm so sorry for asking silly questions, but I'm new to this chart. so if anyone kind enough to help me:

below is my code:

Morris.Donut({
                element: 'donut-chart',
                data: [{
                    label: "Added",
                    value: 30
                }, {
                    label: "Sold",
                    value: 12
                }],
				    colors: ['#414e63', '#e96562'],
                resize: true
            });

every time it initially selects 'Added' value, I've tried flipping position with 'Sold' but no luck.
I think it automatically selects the highest value,

how can I select my desired label? I don't want to select the lowest value coz there will be more items.
so if there's something like select: 'Sold'

Then please let me know.

I'm asking this question coz I didn't understood what to do with

Grab the latest master, then calling select(n) on the object that Morris.Donut(...) returns

Thank you

i have same question, please reply @oesmith

@pierresh
Copy link

Just do like this:

var my_chart = Morris.Donut({
	element: 'chart_test',
	resize: true,
	data: [{
		value: 2,
		label: "good"
	},{
		value: 3,
		label: "not ok"
	}],
});

// Then below, choose which one you want to select
my_chart.select(0); // to select data with "good" label
my_chart.select(1); // to select data with "not ok" label

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

No branches or pull requests

5 participants