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

Programmatically Create Plot Bands for RadHtmlChart

1 Answer 212 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Bethany
Top achievements
Rank 1
Bethany asked on 10 Jun 2015, 08:50 PM

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!

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 12 Jun 2015, 03:54 PM

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
Tags
Chart (HTML5)
Asked by
Bethany
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or