This is a migrated thread and some comments may be shown as answers.

How to draw a line on bar chart?

3 Answers 145 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 18 Jul 2011, 10:40 PM
I am trying to draw a line on a bar chart, and i tried the following code (with the marked zone):

 

 

Dim redZone As New ChartMarkedZone
           redZone.ValueStartY = 100
           redZone.ValueEndY = 100
           redZone.Appearance.Border.Color = Color.Red
           redZone.Appearance.Border.Width = 2
           RadChart2.PlotArea.MarkedZones.Add(redZone)

 

 

This did not work since the line stays behind the bars (Please see the attached). All i need a line over the bars. I was wondering if there is a solution for that. I am currently using 2011 Q1 version.

 



Thank you.

3 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 21 Jul 2011, 12:36 PM
Hi Jacob,

The MarkedZones property by default display behind the chart series.

What could be done in your case is to add another line series that will be dispalyed over the bars. All line series values should be equal so it can be drawn as a straight line.

The line however, will start at the center of your first bar and end at the center of your last bar as well. In order to avoit that, you could try setting the LayoutMode to Normal:
radChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Normal

All the best,
Peshito
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Jacob
Top achievements
Rank 1
answered on 21 Jul 2011, 03:33 PM
Hi Peshito,

Thanks for the reply. When i use the following line, the first and the last bars are getting cut off (Please see attached). Do you have any solution for that?

radChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Normal

More importantly, how can i show additional yaxis labels between the default steps for the line series? For example, on the attached example i would like to see the yaxis number "225" corresponding to green line series. Would that be possible especially without doing yaxis.autoscale = false?

Thanks again.
0
Peshito
Telerik team
answered on 26 Jul 2011, 03:36 PM
Hello Jacob,

You can set the XAxis LayouMode to Between:
radChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Between;

This way your bars will be fully visible. However keep in mind that there will be some empty space at the beginning and at the end of the line.

Regarding your other question, this feature is currently not supported. You can try setting secondary YAxis and define its MinValue, Maxvalue and Step, after setting the AutoScale to False.

For example:
line.YAxisType = ChartYAxisType.Secondary;
radChart.PlotArea.YAxis2.AutoScale = false;
radChart.PlotArea.YAxis2.AddRange(0, 150, 25);


Here you can find more information on how to use Secondary YAxis.

Greetings,
Peshito
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Chart (Obsolete)
Asked by
Jacob
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Jacob
Top achievements
Rank 1
Share this question
or