NeilAlderson Posted February 9, 2008 Report Share Posted February 9, 2008 Hello, Can someone point me to where I'm going wrong? I'm doing a query on an Access database and passing the resultset to a chart control. The data comes back as 4 series so I'm trying to set the SerLeg properties to a human readable string for display but the resulting chart is still displaying the default "Expr1000" etc in the SerLegBox. See the code snippet below. Regards, Neil Code Snippet: reportQuery = "SELECT SUM(IIf((HH15+HH16)>=1 And (HH15+HH16)<=3,1,0)), " + "SUM(IIf((HH15+HH16)>=4 And (HH15+HH16)<=6,1,0)), " + "SUM(IIf((HH15+HH16)>=7 And (HH15+HH16)<=9,1,0)), " + "SUM(IIf((HH15+HH16)>=10,1,0)) " + "FROM Census_Counts"; theChart.DataType[0] = DataType.Default; theChart.DataType[1] = DataType.Default; theChart.DataType[2] = DataType.Default; theChart.DataType[3] = DataType.Default; theChart.Legend[0] = ""; theChart.SerLeg[0] = "Households with 1-3 individuals"; theChart.SerLeg[1] = "Households with 4-6 individuals"; theChart.SerLeg[2] = "Households with 7-9 individuals"; theChart.SerLeg[3] = "Households with 10 or more individuals"; theChart.SerLegBox = true; theChart.AxisX.Title.Text = "Band"; theChart.AxisY.Title.Text = "No. Households"; theChart.AxisY.AdjustScale(); theChart.AxisY.LabelsFormat.Decimals = 0; theChart.Gallery = Gallery.Bar; theChart.LegendBox = false; theChart.PointLabels = true; theChart.Grid = ChartGrid.Horz; theChart.Chart3D = true; theChart.Titles[0].Text = "Household Size in Bands"; cmd.Connection = dbConnection; cmd.CommandText = reportQuery; adapter.SelectCommand = cmd; adapter.Fill(ds); theChart.DataSource = ds.Tables[0]; theChart.Refresh(); Link to comment Share on other sites More sharing options...
maximop Posted February 12, 2008 Report Share Posted February 12, 2008 You are setting the SerLeg text before you bind the data to the chart so your labels seem to be overwritten by the values contained in your dataset. Try setting your SerLeg labels after you bind the data to the chart's data source. Link to comment Share on other sites More sharing options...
NeilAlderson Posted February 25, 2008 Author Report Share Posted February 25, 2008 Aha, so I am. Yep that did it! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.