Page 1 of 2

change axis values of constant lines at run time

Posted: Wed Jan 30, 2013 10:28 am
by stiuser
Hi,
I need to draw two constant lines in report chart. The chart is in a databand and I need to set the axis value of constant lines at run time. Could you please let me know how can I achieve it?

Re: change axis values of constant lines at run time

Posted: Wed Jan 30, 2013 10:58 am
by Alex K.
Hello,

You can use the following code:

Code: Select all

StiChart chart = report.GetComponents()["Chart1"] as StiChart;

Stimulsoft.Report.Chart.StiConstantLines constLine = new Stimulsoft.Report.Chart.StiConstantLines();
constLine.AxisValue = "10";
constLine.LineColor = System.Drawing.Color.Black;
constLine.Text = "Constant Line 1";

chart.ConstantLines.Clear();
chart.ConstantLines.AddRange(new Stimulsoft.Report.Chart.IStiConstantLines[] {
            constLine});
Thank you.

Re: change axis values of constant lines at run time

Posted: Thu Jan 31, 2013 5:50 am
by stiuser
Hi Aleksey,

Thanks for your reply.

But my chart is in a databand and Constant Line Axis value may change from one chart to next chart.
If the chart is not in the databand, we can use the above code.

Thank you

Re: change axis values of constant lines at run time

Posted: Thu Jan 31, 2013 9:47 am
by HighAley
Hello.

Then you should set the Constant Line in the Before Print event of the Chart.

Thank you.

Re: change axis values of constant lines at run time

Posted: Fri Feb 01, 2013 5:56 am
by stiuser
Hi Aleksey,

I am not sure how to add constant lines in before print event.

I have already added below code for setting the text after property of Y axis
this.Chart2_Area.YAxis.Labels.TextAfter =" " + C_Data.Unit;
I have tried to create constant lines in the before print event by following the syntax of the above code. But it is not working.
Could you please let me know the code to add constant lines in Before print event?

Many Thanks.

Re: change axis values of constant lines at run time

Posted: Fri Feb 01, 2013 6:17 am
by Alex K.
Hello,

Please send us your report with test data for analysis.

Thank you.

Re: change axis values of constant lines at run time

Posted: Mon Feb 04, 2013 9:00 am
by stiuser
Hi
I have attached the sample report and test data with this.

Thanks
TestData.zip
Report file with access database
(18.04 KiB) Downloaded 323 times

Re: change axis values of constant lines at run time

Posted: Mon Feb 04, 2013 2:11 pm
by HighAley
Hello.

Please, look at the Before Print event of the Chart in the attached report template.
Report.mrt
(12.8 KiB) Downloaded 474 times
Thank you.

Re: change axis values of constant lines at run time

Posted: Wed Feb 06, 2013 5:08 am
by stiuser
Hello,

Thank you very much.. It works good now.
But the constant line "text" drawn vertically and it is in the right side of the Y axis. Is there any way to draw the "Text" value horizontally and place it in the left side of the Y axis?

I have attached the current chart image and expected chart image with this mail.

Many Thanks
Current and expected chart screenshot
Current and expected chart screenshot
screenshots.JPG (23.23 KiB) Viewed 5307 times

Re: change axis values of constant lines at run time

Posted: Wed Feb 06, 2013 6:47 am
by HighAley
Hello.

Unfortunately, it's impossible to show labels this way now.

Thank you.