|
Line drawing question in FinanceChart. |
Posted by eaglescv on Aug-03-2020 01:00 |
|
Hi
I am trying to draw a line in FinanceChart and I want to draw based on the high or low data of the candle.
exmaple)
FinanceChart m(width);
m.addLine( highdata[200].pixel.x, highdata[200].pixel.y, highdata[200].pixel.x + 100, highdata[200].pixel.y);
I want to get the pixel position of the candle's(array random access index) high or low data.
What should I do? help me plz..
|
Re: Line drawing question in FinanceChart. |
Posted by Peter Kwan on Aug-03-2020 20:28 |
|
Hi eaglescv,
The BaseChart.addLine uses pixel coordinates. Instead of using BaseChart.addLine, you may consider to use Axis.addMark with xZoneColor, which uses data values instead of pixel coordinates. It is like (in C++):
FinanceChart m(width);
....
// Add the main price chart
XYChart *c = m.addMainChart(.....);
....
// Blue color between index = 200 to 210, transparent outside this range.
// (extraPoints is the same extraPoints parameter used in FinanceChart.setData)
int lineColor = c->xZoneColor(200 - extraPoints, Chart::Transparent, c->xZoneColor(210 - extraPoints, 0x0000ff, Chart::Transparent));
// Add the line
c->yAxis()->addMark(highData[200], lineColor)->setLineWidth(2);
Hope this can help.
Regards
Peter Kwan |
Re: Line drawing question in FinanceChart. |
Posted by eaglescv on Oct-06-2020 00:53 |
|
Hi Peter
Thanks to you, the past problem has been solved.
Can you draw them all on just one financial chart?
1. I want to draw a box based on the price of the candle.
2. Can you draw like a green line or like a red line?
Please let me know if there is a way.
Thank you
|
Re: Line drawing question in FinanceChart. |
Posted by Peter Kwan on Oct-06-2020 09:58 |
|
Hi eaglescv,
If you have many different custom objects to draw on the chart, you can use the DrawArea directly. It is like:
FinanceChart m(width);
....
// Add the main price chart
XYChart *c = m.addMainChart(.....);
....
// After adding everything to the FinanceChart, now can add custom drawings
DrawArea *d = c->makeChart();
// Add a line from (x1, y1) to (x2, y2) using the data x, y coordinates. The
// getXCoor and getYCoor will translate them to pixel coordinates. You can add
// horizontal line, vertical line or a line with slope
d->line(c->getXCoor(x1), c->getYCoor(y1), c->getXCoor(x2), c->getYCoor(y2), 0x0000ff, 2);
// You can add rectangles too by providing two opposite corners of the rectangle
d->rect(c->getXCoor(x3), c->getYCoor(y3), c->getXCoor(x4), c->getYCoor(y4),
0x00ff00, 0x7fffff80);
// You can add text as well
c->addText(c->getXCoor(x5), c->getYCoor(y5), "ABCD", "arialbd.ttf", 8, 0x000000);
The data x and y coordinates are the same as in my last email. The x-data coordinate is the arrayIndex - extraPoints, the y-data coordinates is just the price value.
Hope this can help.
Regards
Peter Kwan |
Re: Line drawing question in FinanceChart. |
Posted by eaglescv on Oct-07-2020 01:08 |
|
Thank you for very fast feedback. I`ll try it. |
|