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

Linechart with linqdatasource

1 Answer 50 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Wired_Nerve
Top achievements
Rank 2
Wired_Nerve asked on 02 Jun 2015, 01:03 PM

I have been looking for a working example of a LINE CHART that uses a linqdata source.  They have an example of a bar chart, and I changed out the series type with a telerik:lineseries and it is just not working.  

 

I am sure I am just missing something very easy here...  Does anyone know of an example combining these two?

This should be stupid easy I would think.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 02 Jun 2015, 02:00 PM
Hi,

I have have already replied to the support ticket that was opened by you on the matter, so that I paste my answer for the rest of the community:

You can find the modification of this demo (http://demos.telerik.com/aspnet-ajax/htmlchart/examples/databinding/linqdatasource/defaultcs.aspx), so that a line series is bound to LinqDataSource:

<asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource1_Selecting">

</asp:LinqDataSource>

<div class="demo-container size-wide">

    <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="800px" Height="500px"

        DataSourceID="LinqDataSource1">

        <PlotArea>

            <Series>

                <telerik:LineSeriesDataFieldY="UnitsInStock" Name="Units In Stock">

                    <TooltipsAppearance Visible="false"></TooltipsAppearance>

                </telerik:LineSeries>

                <telerik:ColumnSeries DataFieldY="UnitsOnOrder" Name="Units On Order">

                    <TooltipsAppearance Visible="false"></TooltipsAppearance>

                </telerik:ColumnSeries>

            </Series>

            <XAxis DataLabelsField="ProductName">

                <LabelsAppearance></LabelsAppearance>

                <MajorGridLines Visible="false"></MajorGridLines>

                <MinorGridLines Visible="false"></MinorGridLines>

            </XAxis>

            <YAxis>

                <TitleAppearance Text="Units"></TitleAppearance>

                <MinorGridLines Visible="false"></MinorGridLines>

            </YAxis>

        </PlotArea>

        <ChartTitle Text="Products Balance">

        </ChartTitle>

    </telerik:RadHtmlChart>

</div>


C#:

protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)

{

    NorthwindReadOnlyEntities northwindContext = new NorthwindReadOnlyEntities();

    e.Result = northwindContext.Products.Where(p => p.UnitsOnOrder > 0).Where(p => p.UnitsInStock > 0).Take(5);

}


The above chart renders like that - http://screencast.com/t/fgvrpEkzIM55

You can find the live demos in the installation folder of Telerik UI controls. For example here:

C:\Program Files (x86)\Telerik\UI for ASP.NET AJAX Q1 2015\Live Demos


Let me know if you have any questions on the matter.


Regards,
Danail Vasilev
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
Wired_Nerve
Top achievements
Rank 2
Answers by
Danail Vasilev
Telerik team
Share this question
or