|
Labels in finance chart |
Posted by dave on Jan-23-2023 04:50 |
|
hi,
I have a few questions about labels in the finance chart.
1)My lower label is getting cropped. Can you tell me what I'm doing wrong?
2)Likewise, I'm concerned that a higher label will also get cropped in the future. How can I expand the plot area so it doesn't?
3)for the higher label, the triangle is on the top of the textbox. How do I move it to under the textbox, so it's pointing to the top of the candle?
Below is my code. Please see the attached image.
Thanks!
if (lowPivots.Any(x => x != Chart.NoValue))
{
//lower labels
Layer LLayer = mainChart.addScatterLayer(default, lowPivots.ToArray(), "", Chart.TriangleShape, 8 , 0x000099 , Chart.Transparent);
LLayer.setDataLabelFormat("${value|2}rn{xLabel|hh:nn}" );
ChartDirector.TextBox LBox = LLayer.setDataLabelStyle("Arial", 8);
LBox.setBackground(Chart.Transparent, 0xc8c8c8);
LBox.setAlignment(8);
LLayer.getDataSet(0).setSymbolOffset(0, 5);
}
if(highPivots.Any(x=>x != Chart.NoValue))
{
//higher labels
Layer HLayer = mainChart.addScatterLayer(default, highPivots.ToArray(), "", Chart.InvertedTriangleShape, 8, 0x000099, Chart.Transparent);
HLayer.setDataLabelFormat("${value|2}rn{xLabel|hh:nn}");
ChartDirector.TextBox HBox = HLayer.setDataLabelStyle("Arial", 8);
HBox.setBackground(Chart.Transparent, 0xc8c8c8);
HBox.setAlignment(8);
HLayer.getDataSet(0).setSymbolOffset(0, -40);
}
|
Re: Labels in finance chart |
Posted by Peter Kwan on Jan-23-2023 12:20 |
|
Hi Dave,
In the original "Finance Chart Custom Symbols", under the candlesticks there are the volume bars, so there is no need to reserve additional space for the custom symbols.
If you put the volume bars on a separate indicator chart, you may want to add some margins or scale extensions to the bottom of the main price chart to provide space for the symbols/labels. It ls like:
// Your main price chart
XYChart m = c.addMainChart(....);
// Add 20 pixels empty space below the axis scale
m.yAxis().setMargin(0, 20);
or
// Extend the bottom scale such that at least 10% of the chart height
// is empty. For example, if you data are from 85 to 152, ChartDirector might
// set the axis scale from 60 to 160 (instead of 80 to 160). As there is no data
// between 60 to 85, there will be empty space at the bottom.
m.yAxis().setAutoScale(0.05, 0.1, 0);
See:
https://www.advsofteng.com/doc/cdnet.htm#Axis.setMargin.htm
https://www.advsofteng.com/doc/cdnet.htm#Axis.setAutoScale.htm
Best Regards
Peter Kwan |
Re: Labels in finance chart |
Posted by dave on Jan-23-2023 18:58 |
|
That was perfect!
One last question (I think). How can I move the top label triangle to under the textbox?
Or any type of pointer under the textbox, so, the pointer is closer to the candle, rather than the textbox.
Here is the triangle I'm referring too.
Thanks!
|
Re: Labels in finance chart |
Posted by dave on Jan-23-2023 22:50 |
|
I was able to get this resolved.
thanks! |
|