Hi Guys,
I'm trying to create a chart with multiple line series' below is my code:
string sql = string.Format(@"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) AND (dbo.Product.ProductID = 10) 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, '10/10/2013', 103))"); SqlUtils db = new SqlUtils("Charon"); try { DataTable dt = db.FillTable(sql); RadHtmlChart htmlChart = new RadHtmlChart(); htmlChart.ID = "htmlChart"; htmlChart.Width = Unit.Pixel(680); htmlChart.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; //htmlChart.PlotArea.XAxis.DataLabelsField = row["OrderDate"].ToString(); foreach (DataRow row in dt.Rows) { var lineSeries = new LineSeries { Name = row["Name"].ToString() }; lineSeries.LabelsAppearance.Visible = true; lineSeries.TooltipsAppearance.Color = System.Drawing.Color.White; lineSeries.TooltipsAppearance.DataFormatString = string.Format("{0} x {1}", row["UnitsSold"], row["Name"]); lineSeries.DataFieldY = "UnitsSold"; lineSeries.DataFieldX = "OrderDate"; //SeriesItem seriesItem = new SeriesItem(); var unitsSold = (int)row["UnitsSold"]; //lineSeries.SeriesItems.Add(unitsSold); CategorySeriesItem seriesItem1 = new CategorySeriesItem(); seriesItem1.Y = unitsSold; lineSeries.SeriesItems.Add(seriesItem1); htmlChart.PlotArea.Series.Add(lineSeries); } HtmlChartHolder.Controls.Add(htmlChart); //LineChart.DataSource = trendAnalysisbyDate(1); //LineChart.DataBind(); } finally { db.Close(); }
Example Data & how the chart currently looks is attached...
I've just hidden the Name column.. just a text string..
I want the chart to show Units Sold on the left (y axis) and the order date on the bottom (x axis) and the product name to the be label/ledgend..
Any help would be great. Thanks!