change axis values of constant lines at run time

Stimulsoft Reports.WPF discussion
stiuser
Posts: 12
Joined: Mon Oct 08, 2012 9:14 am

change axis values of constant lines at run time

Post 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?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: change axis values of constant lines at run time

Post 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.
stiuser
Posts: 12
Joined: Mon Oct 08, 2012 9:14 am

Re: change axis values of constant lines at run time

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: change axis values of constant lines at run time

Post by HighAley »

Hello.

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

Thank you.
stiuser
Posts: 12
Joined: Mon Oct 08, 2012 9:14 am

Re: change axis values of constant lines at run time

Post 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.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: change axis values of constant lines at run time

Post by Alex K. »

Hello,

Please send us your report with test data for analysis.

Thank you.
stiuser
Posts: 12
Joined: Mon Oct 08, 2012 9:14 am

Re: change axis values of constant lines at run time

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: change axis values of constant lines at run time

Post 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.
stiuser
Posts: 12
Joined: Mon Oct 08, 2012 9:14 am

Re: change axis values of constant lines at run time

Post 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 5318 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: change axis values of constant lines at run time

Post by HighAley »

Hello.

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

Thank you.
Post Reply