Programmatically Create Plot Bands for RadHtmlChart

2 posts, 0 answers
  1. Bethany
    Bethany avatar
    9 posts
    Member since:
    Mar 2015

    Posted 10 Jun 2015 Link to this post

    Hello,

     I am creating a RadHtmlChart in the code-behind (VB.NET) and would like to know how to create a plot band for the yAxis programmatically? I can't find any documentation online or in the forums. Any help would be greatly appreciated.

     

    Thanks!

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 12 Jun 2015 Link to this post

    Hi Bethany,

    You need to create instances of the same classes you see in the markup. For example, this markup

    <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="760px" Height="420px">
        <PlotArea>
            <XAxis>
                <PlotBands>
                    <telerik:PlotBand From="1" To="2" Color="#e83737" Alpha="100" />
                </PlotBands>
            </XAxis>
            <YAxis>
                <PlotBands>
                    <telerik:PlotBand From="15" To="20" Color="#008de7" Alpha="100" />
                </PlotBands>
            </YAxis>
            <Series>
                <telerik:ColumnSeries Name="Series 1">
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="19" />
                        <telerik:CategorySeriesItem Y="16" />
                        <telerik:CategorySeriesItem Y="23" />
                        <telerik:CategorySeriesItem Y="18" />
                    </SeriesItems>
                </telerik:ColumnSeries>
                <telerik:ColumnSeries Name="Series 2">
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="15" />
                        <telerik:CategorySeriesItem Y="18" />
                        <telerik:CategorySeriesItem Y="18" />
                        <telerik:CategorySeriesItem Y="16" />
                    </SeriesItems>
                </telerik:ColumnSeries>
            </Series>
        </PlotArea>
        <Legend>
            <Appearance Position="Bottom"></Appearance>
        </Legend>
    </telerik:RadHtmlChart>

    Is equivalent to the following combination:

    <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="760px" Height="420px">
        <PlotArea>
            <XAxis>
                <PlotBands>
                    <telerik:PlotBand From="1" To="2" Color="#e83737" Alpha="100" />
                </PlotBands>
            </XAxis>
            <Series>
                <telerik:ColumnSeries Name="Series 1">
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="19" />
                        <telerik:CategorySeriesItem Y="16" />
                        <telerik:CategorySeriesItem Y="23" />
                        <telerik:CategorySeriesItem Y="18" />
                    </SeriesItems>
                </telerik:ColumnSeries>
                <telerik:ColumnSeries Name="Series 2">
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="15" />
                        <telerik:CategorySeriesItem Y="18" />
                        <telerik:CategorySeriesItem Y="18" />
                        <telerik:CategorySeriesItem Y="16" />
                    </SeriesItems>
                </telerik:ColumnSeries>
            </Series>
        </PlotArea>
        <Legend>
            <Appearance Position="Bottom"></Appearance>
        </Legend>
    </telerik:RadHtmlChart>

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim thePlotBand As New PlotBand()
        thePlotBand.From = 15
        thePlotBand.To = 20
        thePlotBand.Color = System.Drawing.ColorTranslator.FromHtml("#008de7")
        thePlotBand.Alpha = 100
        RadHtmlChart1.PlotArea.YAxis.PlotBands.Add(thePlotBand)
    End Sub


    Regards,

    Marin Bratanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top