0

re: ChartsSelectionEvent

asked 2021-09-02 15:36:11 +0800

bztom35 gravatar image bztom35
103 4

I am trying to listen to chart selection event; however, it didn't seem to work. Maybe my approach was not correct.

@Listen("onPlotSelect = #chart") 
    public void showPoint(ChartsSelectionEvent event)   {
             Number pointx = event.getXAxisMax();
                 Number pointy = event.getYAxisMax();
                 Long y =  pointx.longValue();  
                  String formattedDate = TimeUtil.getFormattedTime((Long)y, "MM/dd/yyyy HH:00");
                  String myDateStr = new SimpleDateFormat("MM-dd-yyyy HH:00").format(pointx);             
    System.out.println("OnPlotSelect - Selected Date Time: " + myDateStr  +  " Value: " + pointx);
      }
}
delete flag offensive retag edit

6 Answers

Sort by ยป oldest newest most voted
0

answered 2021-09-06 11:49:27 +0800

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

updated 2021-09-06 11:49:57 +0800

According to Handling Chart Events:

The zkcharts doesn't send this event before you enable "point select" by Charts.getPlotOptions().getSeries().setAllowPointSelect(true); Reference: http://api.highcharts.com/highcharts#plotOptions.series.point.events

Do you enable it?

link publish delete flag offensive edit

Comments

Yes, however, it didn't have the expected results that I was looking for.

bztom35 ( 2021-09-08 00:03:21 +0800 )edit

could you please clearly describe what do you see and what do you expect? the event doesn't send or?

hawk ( 2021-09-08 09:11:23 +0800 )edit
0

answered 2021-09-08 09:11:45 +0800

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

I notice another problem: you should declare a ChartsEvent on your event listener according to the doc.

link publish delete flag offensive edit
0

answered 2021-09-08 10:06:02 +0800

bztom35 gravatar image bztom35
103 4

updated 2021-09-18 04:01:24 +0800

image description

This is what I wanted to do with zkoss charts. I am using point annotation with Jfreechart.

background info:

To enable the dragging, I am listening for a combination of control + shift keys and noticed how the cursor is changing from cursor to hand pointer when enabled dragging.

link publish delete flag offensive edit
0

answered 2021-09-09 11:12:01 +0800

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

According to your video, it seems like you want to move points by dragging, there is a similar example at zkcharts essentail examples.

link publish delete flag offensive edit

Comments

I can't seem to capture the data point while dragging. I looked at the Chart 7.2.x API and can't seem to find a appropriate way to get the data. for(Point point: chart.getSelectedPoints()) { point.update(event.getXAxis(), event.getYAxis(), point.getValue());point.setSelected(false);}

bztom35 ( 2021-09-11 17:08:53 +0800 )edit
0

answered 2021-09-15 15:25:43 +0800

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

updated 2021-09-17 11:57:17 +0800

You can call Point.getY() to get a Point's Y value.

But, currently, dragging point is just a client-side effect, zkcharts doesn't send back the changed Y value back to the server side. After you drag a point, click the point, you call Event.getPoint().getY() still returns the point's original value, not the changed value.


However, dragging points to change its value in a series could be a feature. But considering a dragging move is usually not precise and a chart is usually a reporting tool instead of an input UI.

Could you please provide more details about use cases or related context/application background for us to evaluate this new feature?

link publish delete flag offensive edit

Comments

That would be a great feature to include in the new version. I am trying to modernize some of our web start Java applications. One of the key features is to allow user to use graphical UI for data analytical interpolation. The values interpolated are rounded to the nearest hundred.

bztom35 ( 2021-09-16 00:41:20 +0800 )edit

In the meantime, I can implement the back-end data push to the server with current version; however, as long as I can get the approximate values of the xy coordinates.

bztom35 ( 2021-09-16 00:45:00 +0800 )edit
0

answered 2021-09-17 12:53:09 +0800

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

Maybe "click to add a point" can help you, please see https://www.zkoss.org/zkchartsdemo/dynamicclickto_add

what's the purpose of changing a data points by dragging? to create a different series on-the-fly for presentation or comparison?

I have created a feature https://tracker.zkoss.org/browse/ZKCHARTS-127

Please update use case description there, so the future implementation can fulfill your requirement.

link publish delete flag offensive edit

Comments

Yes, the purpose of dragging on the particular series is to rapidly create a new different dataset for the same series on the fly for comparison. Maybe when you implement this new feature, please include ways to get arbitrary x y values in the plot area. Please see above gif.

bztom35 ( 2021-09-17 16:22:23 +0800 )edit

When I tried to use the "click to add a point" sample, it is sort of work. It is not as smooth as dragging(see above gif). Imagine trying to do that for 200+ points. That's 200+ click on the mouse :-)

bztom35 ( 2021-09-17 16:26:41 +0800 )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-09-02 15:36:11 +0800

Seen: 17 times

Last updated: 1 hour ago

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