0

ZK Charts - Legend index issue

asked 2021-04-22 00:09:15 +0800

bztom35 gravatar image bztom35
103 4

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());

} });

image description

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2021-04-26 12:54:49 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

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().

link publish delete flag offensive edit

Comments

I am trying to get the index of a chart, so that I can perform additional operations based on which chart is shown/hidden. Also, I am trying to figure out how to prevent ZKOSS Charts from auto scales x-axis when a chart is hidden or shown.

bztom35 ( 2021-04-26 13:02:23 +0800 )edit
0

answered 2021-04-26 15:33:09 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

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? image description

but I saw it will change y-axis value when hiding.

link publish delete flag offensive edit

Comments

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 )edit
0

answered 2021-04-27 12:37:03 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

Regarding 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));

link publish delete flag offensive edit
0

answered 2021-07-01 15:30:45 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2021-07-01 15:35:55 +0800

You can call ChartsEvent.getSeriesIndex().

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2021-04-22 00:09:15 +0800

Seen: 11 times

Last updated: Jul 01

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More