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

ASP.NET to C#

2 Answers 71 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Zeshan
Top achievements
Rank 1
Zeshan asked on 30 Jun 2017, 09:16 AM

HI All

I require the code behind in C# equivalent of the following asp.net code , could you help please.

 

<telerik:RadHtmlChart runat="server" ID="LineChart" Width="800" Height="500" Transitions="true">
    <PlotArea>
        <Series>
            <telerik:LineSeries Name="Week 15" MissingValues="Interpolate">
                <Appearance>
                    <FillStyle BackgroundColor="Blue" />
                </Appearance>
                <LabelsAppearance DataFormatString="{0}%" Position="Above" />
                <MarkersAppearance MarkersType="Square" BackgroundColor="Blue" />
                <SeriesItems>
                    <telerik:CategorySeriesItem Y="15" />
                    <telerik:CategorySeriesItem Y="23" />
                    <telerik:CategorySeriesItem />
                    <telerik:CategorySeriesItem Y="71" />
                    <telerik:CategorySeriesItem Y="93" />
                    <telerik:CategorySeriesItem Y="43" />
                    <telerik:CategorySeriesItem Y="23" />
                </SeriesItems>
            </telerik:LineSeries>
            <telerik:LineSeries Name="Week 16" MissingValues="Gap">
                <Appearance>
                    <FillStyle BackgroundColor="Red" />
                </Appearance>
                <LabelsAppearance DataFormatString="{0}%" Position="Above" />
                <MarkersAppearance MarkersType="Square" BackgroundColor="Red" />
                <SeriesItems>
                    <telerik:CategorySeriesItem Y="35" />
                    <telerik:CategorySeriesItem Y="42" />
                    <telerik:CategorySeriesItem Y="18" />
                    <telerik:CategorySeriesItem Y="39" />
                    <telerik:CategorySeriesItem Y="64" />
                    <telerik:CategorySeriesItem Y="10" />
                    <telerik:CategorySeriesItem Y="6" />
                </SeriesItems>
            </telerik:LineSeries>
        </Series>
        <XAxis MajorTickType="Outside" MinorTickType="Outside">
            <Items>
                <telerik:AxisItem LabelText="Monday" />
                <telerik:AxisItem LabelText="Tuesday" />
                <telerik:AxisItem LabelText="Wednesday" />
                <telerik:AxisItem LabelText="Thursday" />
                <telerik:AxisItem LabelText="Friday" />
                <telerik:AxisItem LabelText="Saturday" />
                <telerik:AxisItem LabelText="Sunday" />
            </Items>
            <MajorGridLines Color="#EFEFEF" Width="1" />
            <MinorGridLines Color="#F7F7F7" Width="1" />
            <TitleAppearance Position="Center" RotationAngle="0" Text="Days" />
        </XAxis>
        <YAxis MajorTickSize="1" MajorTickType="Outside" MaxValue="100" MinorTickSize="1"
            MinorTickType="Outside" MinValue="0">
            <LabelsAppearance DataFormatString="{0}%" RotationAngle="0" />
            <MajorGridLines Color="#EFEFEF" Width="1" />
            <MinorGridLines Color="#F7F7F7" Width="1" />
            <TitleAppearance Position="Center" RotationAngle="0" Text="CPU Load" />
        </YAxis>
    </PlotArea>
    <ChartTitle Text="Server CPU Load By Days">
    </ChartTitle>
    <Legend>
        <Appearance Position="Bottom" />
    </Legend>
</telerik:RadHtmlChart>

 

2 Answers, 1 is accepted

Sort by
0
Zeshan
Top achievements
Rank 1
answered on 30 Jun 2017, 09:45 AM

or the code behind in C# equivalent of this one

 

<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="600px" Height="400px">
    <PlotArea>
        <Series>
            <telerik:LineSeries Name="Product 1">
                <SeriesItems>
                    <telerik:CategorySeriesItem Y="15000" />
                    <telerik:CategorySeriesItem Y="23000" />
                    <telerik:CategorySeriesItem Y="10000" />
                </SeriesItems>
            </telerik:LineSeries>
        </Series>
        <XAxis>
            <Items>
                <telerik:AxisItem LabelText="1" />
                <telerik:AxisItem LabelText="2" />
                <telerik:AxisItem LabelText="3" />
            </Items>
        </XAxis>
    </PlotArea>
    <ChartTitle Text="Product sales for 2011">
    </ChartTitle>
    <Legend>
        <Appearance Position="Bottom" />
    </Legend>
</telerik:RadHtmlChart>

0
Eyup
Telerik team
answered on 05 Jul 2017, 05:41 AM
Hello Zeshan,

The programmatic creation logic is similar, you just need to create the control during the Page_Init event handler as demonstrated in the following live sample:
http://demos.telerik.com/aspnet-ajax/htmlchart/examples/serversideapi/programmaticcreation/defaultcs.aspx

You can place a basic PlaceHolder in the aspx page and add the chart to its Controls collection:
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.placeholder(v=vs.110).aspx

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Chart
Asked by
Zeshan
Top achievements
Rank 1
Answers by
Zeshan
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or