asp.net中的条形图 [英] Bar Chart in asp.net

查看:62
本文介绍了asp.net中的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都有条形图的想法,


anyone have idea of bar chart,


<asp:Chart ID="Chart1" runat="server" ImageLocation="~/document/Images_Chart/ChartPic_#SEQ(300,3)" ImageStorageMode="UseImageLocation" Width="800px"  BackGradientStyle="LeftRight">
       <Series>
           <asp:Series Name="Series1" ChartType="Column" ChartArea="ChartArea1"  >


     </asp:Series>


       </Series>
       <ChartAreas>
           <asp:ChartArea Name="ChartArea1" Area3DStyle-IsClustered="true">


           </asp:ChartArea>
       </ChartAreas>
       <BorderSkin SkinStyle="Emboss" />    </asp:Chart>







private void loadChart()
   {
       DataBase12 obj = new DataBase12();

       DataSet ds_chart = new DataSet();
       IFormatProvider cult = new CultureInfo("en-us");

       ds_chart = obj.GetFeedBackChartReport(DateTime.ParseExact(txtFromdt.Text.ToString(), "dd/MM/yyyy", cult), DateTime.ParseExact(txtTodt.Text.ToString(), "dd/MM/yyyy", cult));
       if (ds_chart.Tables[0].Rows.Count == 0)
       {
           pnl_Chart.Visible = false;
           LblErrorMessage.Text = "No records found !";
       }
       else
       {

           Chart1.DataSource = ds_chart;
           Chart1.DataBind();
           pnl_Chart.Visible = true;
           LblErrorMessage.Text = "";
       }
   }


在数据库i hv 2中,问题q1,q2是否存在q1 = 1,如果否q1 = 2,与q2相同
我用这个sp


in database i hv 2 question with q1,q2 if yes q1=1 if no q1=2 ,same for q2
i use this sp

Create PROC  [dbo].[usp_GetFeedbackReport] 
@FromDate Datetime,
@ToDate datetime	
AS
BEGIN
	
	SET NOCOUNT ON;
declare @q1yes int
declare @q1no int
declare @q2yes int
declare @q2no int
  
   select @q1yes=count(q1)  from tbl_feedbackDetails where q1=1 
  and Createdon >= @FromDate AND Createdon <= @ToDate
GROUP BY convert(varchar,Createdon,103)
ORDER BY convert(varchar,Createdon,103) 

  select @q1no=count(q1)  from tbl_feedbackDetails where q1=2 
  and Createdon >= @FromDate AND Createdon <= @ToDate
GROUP BY convert(varchar,Createdon,103)
ORDER BY convert(varchar,Createdon,103) 

 
    select @q2yes=count(q2)  from tbl_feedbackDetails where q2=1 
  and Createdon >= @FromDate AND Createdon <= @ToDate
GROUP BY convert(varchar,Createdon,103)
ORDER BY convert(varchar,Createdon,103) 

  select @q2no=count(q2)  from tbl_feedbackDetails where q2=2 
  and Createdon >= @FromDate AND Createdon <= @ToDate
GROUP BY convert(varchar,Createdon,103)
ORDER BY convert(varchar,Createdon,103) 

END



我的条形图未显示我想在x轴上做错的地方,我想显示q1,q2



my bar chart is not displaying where i m doing wrong in x-axis i want show q1,q2

推荐答案

主要是您尚未设置图表的值字段
XValueMember& YValueMember

Main thing is you have not set value field of chart
XValueMember & YValueMember

<asp:series name="Series1" charttype="Column" chartarea="ChartArea1" xmlns:asp="#unknown">
XValueMember="XField" YValueMember="YField" 
 ></asp:series>



您的sp是四个结果集.
你不能这样
Chart1.DataSource = ds_chart;
您必须为datasourcr提供一些表格.您首先应该尝试一些基本的条形图示例.用简单的select语句.然后分析您所要做的.创建正确的sp&然后在图表中实施它.创建sp时在单个表中获取数据.



Your sp is resulting four resultset.
You cant like this
Chart1.DataSource = ds_chart;
YOu have to give some table to datasourcr. You should first try some basic example for bar chart. With simple select statement. Then analyze what you have to do. Create correct sp & then implement it in chart. Take data in single table while creating sp.


hi,



http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx[^]

Download the projects and see the examples.

Thanks,
Viprat


这篇关于asp.net中的条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆