In flot, how can I create a pie chart where each wedge is a link to a different web-page?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
I know this is an old thread but I have discovered another way of doing this.
Make sure
grid
is set toclickable
Bind a click function to the element and use javascript to redirect to the url.
Adding to the answer by Derek Kurth...
It looks like flot is ignoring any additional objects that we include in the JSON. For example when I used
it worked without any trouble and I was able to access the data from the event handler like
I am new to this flot library and not great at JavaScript. So probably this is not the right way to do things but it works. I have always felt that embedding additional information in UI elements in HTML is a pain :(
I gave it a shot, but I wasn't able to do it. I started with this example, then added:
right above the "pie: {" line. Then I added a plotclick function at the end:
You'll see the "click!" message, but "item" has no properties.
I was thinking you'd just add URLs to the data ojects, then forward the browser to the appropriate URL from within the plotclick function. If you figure it out, I'd be interested to know!
Update: Here's something that might work -- it just turns the labels into links. Put the URLs in your data like this:
Then set the labelFormatter to something like:
Clicking in the pie wedges themselves still does nothing special, though.