本文介绍了为什么条形图列不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 hiii ...实际上我把所有代码都放到了条形图中,但是条形图列没有显示出来。我想我的图表系列有问题@@ 下面是我的aspx代码 < asp:Chart ID = Chart1 runat = server BackColor = 灰色 EnableViewState = True 宽度 = 502px > < 系列 > < asp:Series 名称 = Series1 BackImageTransparentColor = 灰色 BackSecondaryColor = RosyBrown BorderColor = 透明 BorderDashStyle = NotSet ChartArea = ChartArea1 颜色 = 紫色 LabelBackColor = 255,128,0 MarkerBorderColor = Lime MarkerColor = 蓝色 ShadowColor = BlueViolet > < / asp:Series > < / Series > < ChartAreas > < asp:ChartArea 名称 = ChartArea1 BackColor = Khaki BorderColor = MediumAquamarine > ; < / asp:ChartArea > < / ChartAreas > < 标题 > < asp:标题 BackColor = 白色 BackImageAlignment = Top ForeColor = 栗色 名称 = 预测结果 文本 = 预测结果 > < / asp:title > < /标题 > < / asp:Chart > ; 这是我的c#代码 protected void Button5_Click( object sender,EventArgs e) { int i = int .Parse(DropDownList1.SelectedValue); SqlConnection connection = new SqlConnection( 数据Sourceaaa; Initial Catalog = System; Integrated Security = True); connection.Open(); SqlDataAdapter fdm = new SqlDataAdapter( 选择([月] = 1时的情况,然后是[月] = 2时的'1月',然后是[月] = 3时的'2月',然后是[月] = 4时的'3月'然后是[月]时的'4月' = 5然后'May'当[MONTH] = 6然后'June'当[MONTH] = 7然后'July'当[MONTH] = 8然后'August'当[MONTH] = 9然后是'September'当[MONTH] = 10然后'十月'当[月] = 11然后'十一月'当[月] = 12然后'十二月'结束)作为月,总和(需求)作为重新订购的结果,其中id =' + i +(span class =code-string> '和[Month] in(1,2,3,4,5,6,7,8,9) ,[月]按[月]顺序分组;,连接); DataSet ds = new DataSet(); fdm.Fill(ds); Chart1.DataSource = fdm; Chart1.ChartAreas [ ChartArea1]。AxisX.Title = 月; // 这里我给出了y轴的标题 Chart1 .ChartAreas [ ChartArea1]。AxisY.Title = 结果; // 这里我将x轴值与图表控件绑定 Chart1.Series [ Series1]。XValueMember = 月; // 这里我将y轴值与图表控件绑定 Chart1.Series [ Series1]。YValueMembers = result; Chart1.DataBind(); fdm.Dispose(); connection.Close(); }} 我应该怎么做才能看到图表系列?请帮我提前谢谢:)解决方案 尝试分离数据库逻辑。请看下面的链接它会对你有所帮助 条形图 hiii... actually i put all the code to make the bar chart but the barchart column do not showing up. i think i got problem on the chart series @@ below is my aspx code<asp:Chart ID="Chart1" runat="server" BackColor="Gray" EnableViewState="True" Width="502px"> <Series> <asp:Series Name="Series1" BackImageTransparentColor="Gray" BackSecondaryColor="RosyBrown" BorderColor="Transparent" BorderDashStyle="NotSet" ChartArea="ChartArea1" Color="Purple" LabelBackColor="255, 128, 0" MarkerBorderColor="Lime" MarkerColor="Blue" ShadowColor="BlueViolet"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1" BackColor="Khaki" BorderColor="MediumAquamarine"> </asp:ChartArea> </ChartAreas> <Titles> <asp:Title BackColor="White" BackImageAlignment="Top" ForeColor="Maroon" Name="Forecast result" Text="Forecast result"> </asp:Title> </Titles> </asp:Chart>this is my c# codeprotected void Button5_Click(object sender, EventArgs e){ int i = int.Parse(DropDownList1.SelectedValue); SqlConnection connection = new SqlConnection("Data Sourceaaa;Initial Catalog=System;Integrated Security=True"); connection.Open(); SqlDataAdapter fdm = new SqlDataAdapter("select (case when [Month] = 1 then 'January' when [Month] = 2 then 'February'when [Month] = 3 then 'March' when [Month] = 4 then 'April'when [MONTH] = 5 then 'May'when [MONTH] = 6 then 'June' when [MONTH] = 7 then 'July' when [MONTH] = 8 then 'August' when [MONTH] = 9 then 'September' when [MONTH] = 10 then 'October' when [MONTH] = 11 then 'November' when [MONTH] = 12 then 'December' end) as Month, sum(demand) as Result from reorder where id ='" + i + "' and [Month] in (1, 2, 3, 4,5,6,7,8,9,10,11,12) group by [Month] order by [Month];", connection); DataSet ds = new DataSet(); fdm.Fill(ds); Chart1.DataSource = fdm; Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Month"; // here i am giving the title of the y-axis Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Result"; // here i am binding the x-axisvalue with the chart control Chart1.Series["Series1"].XValueMember = "Month"; // here i am binding the y-axisvalue with the chart control Chart1.Series["Series1"].YValueMembers = "result"; Chart1.DataBind(); fdm.Dispose(); connection.Close();}}what should i do so i the chart series can be seen? please help me thank you in advance :) 解决方案 Try to separate the database logic.Please see the below link it will help you Bar Chart 这篇关于为什么条形图列不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 18:24