ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Can not sync an additional x axis with the primary x axis
Posted by Robert Nagy on Aug-19-2016 20:37
Attachments:
Dear Peter,

I am trying to use two axes on the bottom of a spline layer to represent hours and day names too. The hour labels are displayed every four hours from Monday to Sunday and the days are displayed on a new axis. My problem is that I cannot achieve that the second label ticks synced with the hour labels (at midnight) and having the day labels center aligned (between two ticks) while all the hours (with 4 hour step) shown for the whole week.
Here is what I have now:
current situation.png
Then I added sync:
try2.png
Then I added label offset for the second axis:
try3.png

A sample java function is attached to create an XYChart.
Please let me know what I am doing wrong.
Thanks in advance!

Best regards,
Robert
current situation.png
double axis.java
double axis.java

7.93 Kb
    
try2.png
try3.png

  Re: Can not sync an additional x axis with the primary x axis
Posted by Peter Kwan on Aug-19-2016 22:56
Hi Robert,

If you have 7 days of data (eg. from Mon 00:00:00 to next Mon 00:00:00). there should be 8 labels (from Mon to next Mon). If you have 6 days of data, there should be 7 labels (from Mon to Sun). For your case, you have 6 days 23 hours 30 minutes of data. So it should have something between 7 and 8 labels. No matter you use 7 or 8 labels, the alignment will not be correct. To align the labels, the best method is for the two axes to use the same number of labels. In this way, the labels will always synchronize.

In your code, the top axis has 336 labels in the labels array. So the DAYS array should have 336 labels too. You can put Mon", "Tue", ... "Sun" at the position that corresponds to the "00:00" in the labels array, and put "" (empty string) in all other positions.

Hope this can help.

Regards
Peter Kwan

  Re: Can not sync an additional x axis with the primary x axis
Posted by Robert Nagy on Aug-30-2016 23:34
Hi Peter,

Thank you it worked!

Now I have to implement a zooming functionality for this kind of data input (one week data range from Mon 0:00 till Sun 23:45) regardless of which week is it. I saw the zoomscrolltrack.java example program which is a great start point for me.
Is there any suggestion from your side how to deal with viewport time ranges (the model of the view port), since I have no specific week (Date range)?

Thanks in advance and best regards,
Robert

  Re: Can not sync an additional x axis with the primary x axis
Posted by Peter Kwan on Aug-31-2016 15:44
Hi Robert,

There are several method. You can consider to just fix the starting point to an arbitrary date which is a Monday (such as Jan 1, 2001). So the time range is always Jan 1, 2001 00:00:00 to Jan 6, 2001 23:45. In the label formatting, you can format the labels as {value|w hh:nn} or something similar which does not display the date yyyy-mm-dd.

Hope this can help.

Regards
Peter Kwan

  Re: Can not sync an additional x axis with the primary x axis
Posted by Robert Nagy on Sep-08-2016 13:28
Hi Peter,

It helped! Thank you!

Is it also possible with ChartViewer to drag hotspots and drop them along the y axis? I mean temporally change the y value for a certain x coodinate? I can imagine that using hotspotDragged event we can store the x coordinate and on a mouse released (or hotSpotReleased?) we can calculate the new y value.  I need only points and not lines (later the user accept the changes and the chart dataset will be updated with the newly created dots/hotspots). This is a kind of edit mode. But how to show the new data point on the chart? On a new layer? With a new dataset?
Any suggestions are welcome!

Kind regards,
Robert

  Re: Can not sync an additional x axis with the primary x axis
Posted by Peter Kwan on Sep-09-2016 00:01
Hi Robert,

You may consider to use the "dynamic layer" to draw the data point. To get started, you can try the "Programmable Track Cursor" sample code. In those sample code, when the mouse moves over the chart, a track cursor with some dots and text will be drawn on the chart and they follows the mouse movement. For your case, you can use the same method to draw the dot.

Hope this can help.

Regards
Peter Kwan