|
the correct value at FinanceChart ## QT |
Posted by potatokid on Mar-15-2016 15:58 |
|
Hi, I want to show the y-value in finance chart, but the value at volIndicator chart seems something wrong, can you help me.
Attachments/w.png
thanks.
c->addVolIndicator(indicatorHeight, 0x99ff99, 0xff9999, 0x808080);
double ttx = ((XYChart *)m->getChart(i))->getXValue(mouseX);
double tty = ((XYChart *)m->getChart(i))->getYValue(mouseY);
|
Re: the correct value at FinanceChart ## QT |
Posted by Peter Kwan on Mar-16-2016 03:15 |
|
Hi potatokid,
The coordinate used in getYValue should be relative to the chart of which the method is called. It means for the ((XYChart *)m->getChart(i)) (the volume chart), it should be relative to the volume chart. On the other hand, the mouse coordinates reported by Qt is relative to the entire FinanceChart. So we need to adjust the mouse coordinate from the offset of the volume chart inside the FinanceChart. The offset can be retrieved by using BaseChart.getAbsOffsetY.
As an example, in our "Finance Chart Track Line (QT)", we use the BaseChart.getAbsOffsetY to compute the position of objects (such as the track line) inside the indicator charts.
For your case, I think you may modify the code to:
XYChart *c = (XYChart *)m->getChart(i);
double ttx = c->getXValue(mouseX - c->getAbsOffsetX());
double tty = c->getYValue(mouseY - c->getAbsOffsetY());
Hope this can help.
Regards
Peter Kwan |
Re: the correct value at FinanceChart ## QT |
Posted by potatokid on Apr-06-2016 12:22 |
|
thank you, it works |
|