C# Telerik HtmlChart多线系列

C# Telerik HtmlChart多线系列,c#,asp.net,sql,telerik,C#,Asp.net,Sql,Telerik,2个问题,我正在尝试创建一个具有简单Y轴和X轴的图表。Y轴是“单位”X轴是日期范围(1周),下面是我的SQL查询: SELECT dbo.ProductSales.OrderDate, dbo.ProductSales.ProductID, dbo.ProductSales.UnitsSold, dbo.Product.Name FROM dbo.ProductSales INNER JOIN

2个问题,我正在尝试创建一个具有简单Y轴和X轴的图表。Y轴是“单位”X轴是日期范围(1周),下面是我的SQL查询:

SELECT     dbo.ProductSales.OrderDate, dbo.ProductSales.ProductID, dbo.ProductSales.UnitsSold, dbo.Product.Name
                                FROM         dbo.ProductSales INNER JOIN
                  dbo.Product ON dbo.ProductSales.ProductID = dbo.Product.ProductID

                                WHERE     (DistributionCentreID = 3)
                                GROUP BY dbo.ProductSales.OrderDate, dbo.ProductSales.ProductID, dbo.ProductSales.UnitsSold, dbo.Product.Name
                                HAVING      (OrderDate >= CONVERT(DATETIME, '01/10/2013', 103)) AND (OrderDate <= CONVERT(DATETIME, '07/10/2013', 103))
选择dbo.ProductSales.OrderDate、dbo.ProductSales.ProductID、dbo.ProductSales.UnitsSold、dbo.Product.Name
来自dbo.ProductSales内部联接
dbo.ProductSales.ProductID=dbo.Product.ProductID上的dbo.Product
其中(DistributionCenter=3)
按dbo.ProductSales.OrderDate、dbo.ProductSales.ProductID、dbo.ProductSales.UnitsSold、dbo.Product.Name分组

具有(OrderDate>=CONVERT(DATETIME,'01/10/2013',103))和(OrderDate以下是如何在RadHtmlChart中显示日期值:

这将向您展示如何使用数据导航预先选择给定的一周,并让用户浏览所有数据:

要以编程方式创建系列及其项,请检查其API:

序列项具有可以将y值作为参数的构造函数

如果只需要一个星期,调整SQL查询只返回相关数据(您似乎已经有了这个数据,您可以考虑使用参数来从代码中获取日期):

var htmlChart = new RadHtmlChart
                        {
                            ID = "htmlChart",
                            Width = Unit.Pixel(680),
                            Height = Unit.Pixel(400)
                        };

    htmlChart.Legend.Appearance.Position = ChartLegendPosition.Bottom;

    htmlChart.PlotArea.XAxis.TitleAppearance.Text = "Date";
    htmlChart.PlotArea.YAxis.TitleAppearance.Text = "Units Sold";

    htmlChart.PlotArea.XAxis.MajorTickType = TickType.Outside;

    htmlChart.PlotArea.XAxis.MinorTickType = TickType.Outside;

    List<productSalesTrend.productsalesTrendbyDates> data = trendAnalysisbyDate(1);

    foreach (string product in data.GroupBy(x => x.productName).Select(x => x.Key))
    {
        IEnumerable<productSalesTrend.productsalesTrendbyDates> productData = data.Where(x => product != null && x.productName == product);

        foreach (var productsalesTrendData in productData)
        {

            LineSeries areaSeries = htmlChart.PlotArea.Series[0] as LineSeries;




        }

    }

    HtmlChartHolder.Controls.Add(htmlChart);