-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Help! I am trying to implement the events that show and hide series in pie chart but do not recognize or execute those events.
This is my implementation:
chart.addEventListener (ChartsEvents.ON_PLOT_HIDE, new EventListener <Event> () {
public void onEvent (Event event) throws Exception { // ... }
});
Please someone who can guide me ?. The version of zk I use is ZK 8.5.1.2 EE
ON_PLOT_HIDE
is fired when you click a legend to hide a series.
I don't understand the problem you encounter. Doesn't the event ON_PLOT_HIDE
fire in your environment? or do you need to hide a series?
please read the related example https://github.com/zkoss/zkchartsessentials/blob/master/src/main/webapp/event/events.zul
Maybe it can help you.
ON_PLOT_HIDE
/ ON_PLOT_SHOW
are not applicable for a pie chart. Because when you click a legend of a pie chart, it hides a point instead of a series. Those 2 events are fired when you hide a series.
ON_PLOT_LEGEND_ITEM_CLICK
could be an alternative, but it's also not applicable on a pie chart.
Another option is to listen to ON_PLOT_SELECT
, let a user clicks a division of a pie chart.
Thank you very much for your contribution, in fact I already probe the events that you comment but here the question is that additionally I need that the points of the pie chart are not hidden, I need to remove that effect that they are not hidden from the click.
As mentioned by Hawk the Pie chart legend hides points instead of series. This is reflected in the Highcharts JS API on plotOptions.pie.point.events -> leading to the official example.
Since the ZK Charts API doesn't duplicate the full set of properties it was designed for extensibility.
So in order to define a client side event listener you can use the API method addExtraAttr
which allows JSON or JavaScript values containing functions.
chart.getPlotOptions().getPie().addExtraAttr("point",
new JavaScriptValue("{ events: { legendItemClick: e => false } }"));
The above will add an event listener for legendItemClick
returning false ... ignoring the event, and keeping the chart slice visible.
(For older browsers you can replace e => false
with function(event) {return false;}
)
Asked: 2019-05-31 00:01:35 +0800
Seen: 19 times
Last updated: Jun 12 '19