How to draw a line on bar chart?

Thread is closed for posting
4 posts, 0 answers
  1. Jacob
    Jacob avatar
    6 posts
    Member since:
    Jul 2011

    Posted 18 Jul 2011 Link to this post

    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.

  2. Peshito
    Admin
    Peshito avatar
    581 posts

    Posted 21 Jul 2011 Link to this post

    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!

  3. Jacob
    Jacob avatar
    6 posts
    Member since:
    Jul 2011

    Posted 21 Jul 2011 Link to this post

    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.
  4. Peshito
    Admin
    Peshito avatar
    581 posts

    Posted 26 Jul 2011 Link to this post

    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!

Back to Top