-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I can't seem to get the series ID index of chart legend. It always return -1 regardless which legend that I clicked on.
chartFlows.addEventListener(ChartsEvents.ON_PLOT_LEGEND_ITEM_CLICK, new EventListener<ChartsEvent>() {
@Override
public void onEvent(ChartsEvent event) {
Series series = (Series) event.getSeries();
System.out.println("Selected series: " + series.getIndex());
} });
I have posted the bug https://tracker.zkoss.org/browse/ZKCHARTS-115
Could you tell me your requirement? We can find an alternative without using getIndex()
.
Since event.getSeries()
is correct, could you implement your requirement with Series
?
About "auto scales x-axis when a chart is hidden or shown", I show and hide a series and don't see x-axis auto-scale. Could you provide a simple example?
but I saw it will change y-axis value when hiding.
Here's example that the chart will auto scaled both x and y axis. Is there a way to controller it from auto scaling. https://www.zkoss.org/zkchartsdemo/splineirregulartime
bztom35 ( 2021-04-27 01:48:16 +0800 )editRegarding the example, https://www.zkoss.org/zkchartsdemo/splineirregulartime, you can set an axis min value to avoid auto-scale:
chart.getXAxis().setMin(getDate(1970, 9, 9));
You can call ChartsEvent.getSeriesIndex()
.
I was hoping to take advantage of the built-in ZK Charts legend(hidden/shown series); unfortunately, the chart framework has not yet supported the chart series index retrieval. On the bright side, I was able use checkboxes to artificially tied to a particular series and toggle on/off according. It's not the most efficient solution; but it will do for now. Thanks for your time for looking into this issue.
Asked: 2021-04-22 00:09:15 +0800
Seen: 17 times
Last updated: Oct 02 '21