|
Adding small lines as threshold to a chart |
Posted by prem on Feb-11-2015 02:03 |
|
Hi Peter,
I want to add the green/orange colored lines in a chart like the attached ones.
Is there a way to do it? I have checked the addzones but it adds on entire chart. I want
the line to be restricted to x,y values.
Thanks
|
Re: Adding small lines as threshold to a chart |
Posted by Peter Kwan on Feb-12-2015 01:35 |
|
Hi prem,
There are several methods.
(a) If the length of the line is specified in pixels, while the vertical position of the line is
specified in terms of y data value, you may add a Box-Whisker Layer with just one data
set for the median line (with all other data series set to an empty array or null or
something equivalent, depending on your programming language). In this way, the symbol
will just be a horizontal line. You can use BoxLayer.setDataWidth to set the horizontal
length of the line in pixel units.
(b) If the end points of the line is specified in x and y data values, you can simply add a
Line Layer with just two data points. This will form a short line segment. With 4 such
layers you can obtain the 4 lines you need.
(c) You can use Axis.addMark to add mark lines. Although the mark line will run from the
left side of the plot area to the right side, you can use an "xZoneColor" as a line color.
The xZoneColor can be configured such that the the color is transparent except when
the x-coordinate is within certain x-data values. In this way, the visible line will just be a
short segment within the specified x-data values.
The key to all of the above is to determine the correct x and y coordinates to use. It
depends on your chart type and how the x-axis and y-axis are configured. For example,
to add the line segment as a LineLayer in Java, the code is like:
double[] xCoor = ...;
double[] yCoor = ....'
LineLayer layer = c.addLineLayer(yCoor, 0xff0000);
layer.setXData(xCoor);
If you need more help, please let me know what is your programming language, and the
how your chart is configured, in particular how is the x-axis and y-axis configured. If you
can inform me of your charting code, it can help me to understand the chart
configuration.
Regards
Peter Kwan |
Re: Adding small lines as threshold to a chart |
Posted by prem on Feb-14-2015 21:42 |
|
Hi Peter,
Im using php for creating a finance chart.
$c->setData($timeStamps, $highData, $lowData, $openData, $closeData, $volData,
$extraDays);
timestamp is in seconds. |
Re: Adding small lines as threshold to a chart |
Posted by Peter Kwan on Feb-17-2015 05:56 |
|
Hi prem,
For your case, you may use the Axis.addMark method to add a mark line to the chart you
want the mark line to appear. For example, if you want to add the line to the main price
chart, the code is like:
# The main price chart. We save the return value to a variable so we can use it
# to add a mark line.
$m = $c->addMainChart(240);
# A mark line at y = 130, which is only visible between the 41st to 51st candlesticks.
$m->yAxis->addMark(130, $m->xZoneColor(40, Transparent,
$m->xZoneColor(50, 0xff0000, Transparent)));
Hope this can help.
Regards
Peter Kwan |
|