|
Volume Bar leadvalue? |
Posted by Steve on Jun-23-2011 08:23 |
|
When I create a HLOCLayer and then setColorMethod, I can set the leadval. Is there something similar for the BarLayer? |
Re: Volume Bar leadvalue? |
Posted by Peter Kwan on Jun-24-2011 04:43 |
|
Hi Steve,
In the HLOCLayer, the color of the symbol can depend on the data value of an earlier symbol. That's why the leadValue is needed to provide the leadValue to compute the color of the first symbol (which does not have an earlier symbol).
For the BarLayer, the bar color does not depend on the value of another other bar, so the leadValue is not needed.
If you are referring to the "Volume Bars" in the FinanceChart, it is achieved by separating the volume data into 3 groups - for up days, down days, and neutral days. For each group, a DataSet is added to a BarLayer. The data set for each group only have a single color, so there is no need to have a leadValue for the BarLayer or for the DataSet.
The actual code that needs a lead value is the algorithm that separates the volume data into 3 groups. In FinanceChart, this is achieved by using the extraPoints parameter in setData. Basically, your data can include one or more extra lead values when you pass them to FinanceChart. The FinanceChart will use these lead values to compute the colors.
Hope this can help.
Regards
Peter Kwan |
Re: Volume Bar leadvalue? |
Posted by Steve on Aug-02-2011 00:58 |
|
Hi Peter,
Yes, I am referrin to the volume bars in a financechart.
Do you have some sample code to achieve this? Currently I create the bar charts by calling:
BarLayer volBar = c.addVolBars(70, 0x3300FF, 0xFF66FF, 0x3300FF); |
Re: Volume Bar leadvalue? |
Posted by Peter Kwan on Aug-02-2011 01:42 |
|
Hi Steve,
If you are using the FinanceChart object, all financial charts sample code in ChartDirector handles the lead value by using a non-zero "extraPoints" parameter in setData. You may refer to any FinanceChart sample code for an example (see "Finance Chart (1)", "Finance Chart (2)" or "Interactive Financial Chart").
The code is like:
//extraDays must be greater than zero if you need a lead value
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays);
If you need to plot the chart for exactly the last 30 days, you may obtain at least 31 days of data, and set the extraDays to at least 1. The FinanceChart will be the extra day as the lead value.
If for some reason, you must get 30 days of data to plot a 30 days chart, you may artifically insert an additional value as the first day to create a 31 days data series. The most common method is to simply duplicate the data for the first day.
Hope this can help.
Regards
Peter Kwan |
Re: Volume Bar leadvalue? |
Posted by Steve on Aug-02-2011 01:55 |
|
Hi Peter,
Sorry, I was referring to adding the 3 volume bars so that I could draw them with the correct colors.
The barchart on the top is drawn using
FinanceChart c = new FinanceChart(Convert.ToInt32(width.Value));
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays);
BarLayer volBar = c.addVolBars(70, 0x3300FF, 0xFF66FF, 0x3300FF);
The one on the bottom happens when I try to
BarLayer volBar = mc.addBarLayer();
volBar.addDataSet(volData, 0x3300FF);
notice the color is wrong and it doesn't use the scale.
|
Re: Volume Bar leadvalue? |
Posted by Steve on Aug-03-2011 00:00 |
|
nevermind.. i found the code in the custom.FinanceChart code. I will change my code to use this instead. thanks |
|