|
watermark some text |
Posted by dave on Jan-27-2023 18:44 |
|
hi Peter,
I'm trying to add some background text to the finance charge. The text is in front of my lines.
How do I send it behind the lines?
I'm open to either changing how I draw my lines or how I write the text.
Here is the code:
// Add low of day
LineLayer layer0 = mainChart.addLineLayer(new double[] { (double)zone.low, (double)zone.low }, 0xff0000);
layer0.setXData(new double[] { zone.startValue, zone.endOfDayXValue });
layer0.setLineWidth(1);
//add watermark text
var waterMark = c.addText(finalWidth/ 2, finalHeight / 2, data.Symbol, "Verdana Bold", 24, Chart.CColor(Color.Gainsboro));
waterMark.setZOrder(Chart.GridLinesZ);
Thanks!
|
Re: watermark some text |
Posted by Peter Kwan on Jan-28-2023 03:22 |
|
Hi Dave,
I suspect it is because your waterMark is added to the entire FinanceChart "c", while your line is added to the "mainChart".
The FinanceChart is just a container for other charts (the mainChart and the indicator charts). The FinanceChart itself does not have grid lines, so the setZOrder(Chart.GridLinesZ) has no effect. Only XYChart objects (like the mainChart) has grid lines.
For your case, I think you want the text to be in front of the plot area background, but behind the data lines. This can only be done by adding the text to the mainChart. An example is:
var waterMark = mainChart.addText(mainChart.getWidth()/2, mainChart.getHeight()/2, data.Symbol, "Verdana Bold", 24, Chart.CColor(Color.Gainsboro));
waterMark.setZOrder(Chart.GridLinesZ);
Another method is to use a semi-transparent color for the text, so you can see through the text.
Best Regards
Peter Kwan |
Re: watermark some text |
Posted by dave on Jan-28-2023 04:03 |
|
ahh..makes total sense.
That fixed it!
You rock. |
|