|
y-Axis scaling |
Posted by Erich on Aug-19-2017 19:23 |
|
Hi,
I want to realize scaling the y-Axis dynamically on a financial Chart. When the user holds down the mouse button on the y-axis and moves vertically I want to scale the affected y-axis. I think I've understanding the scaling of the axis, but I've no glue how to get an event when the user drags on the axis. Could you please advise? |
Re: y-Axis scaling |
Posted by Erich on Aug-19-2017 19:28 |
|
forgot environment...: winchart viewer with c# |
Re: y-Axis scaling |
Posted by Peter Kwan on Aug-19-2017 22:58 |
|
Hi Erich,
There are several methods. Personally, I would use the most direct method as follows:
(a) When the user press the mouse button (mouse down), your code can determine if the user has clicked on the y-axis. This is possible because your code knows the dimension and position of all the indicator charts in a FinanceChart (these parameters are specified by your code). The position of the y-axis from the chart border can also be specified by your code using FinanceChart.setMargins, and the default value is 40 pixels.
(b) When the user move the mouse while the button is still pressed, if the mouse is originally on an axis when the mouse was pressed, you can update the scale of that axis.
Hope this can help.
Regards
Peter Kwan |
Re: y-Axis scaling |
Posted by Erich on Aug-20-2017 02:35 |
|
Hi Peter,
many thanks for your verry prompt reply
I gave it a try and it seems ok in a prototype.
One further question:
my finacial Chart is build up dynamically with some indicators. Is there way to find out the position of the main chart (and other Charts) on the mouse event or do I have to track that during Building the chart? The main Chart can be the first one but ther also can be indicators before.
So: it would be fine to be able to identify the chart when I click on the y-axis. Here I would have the y-coordiante of the mouseclick and it would be fine to get the corresponding chart.
Is that possible to realize?
br
Erich |
Re: y-Axis scaling |
Posted by Peter Kwan on Aug-20-2017 21:08 |
|
Hi Erich,
You can use BaseChart.getAbsOffsetY to obtain the y-coordinate of the top-left corner of the chart inside the FinanceChart. For example:
XYChart mainChart = c.addMainChart(.....);
......
int yOffset = mainChart.getAbsOffsetY();
You can iterate the charts (using MultiChart.getChart to try each chart in sequence) to see the index of the chart that the user has clicked on. For example, if the user clicks on the y-axis of the second chart and then drag it, you can update the y-axis scale of the second chart.
Regards
Peter Kwan |
Re: y-Axis scaling |
Posted by Erich on Aug-21-2017 05:07 |
|
Hello Peter,
that solved my Problem.
Many thanks for your support also on saturday and sunday - that's really great |
|