zoukankan      html  css  js  c++  java
  • Chart控件使用初步

    学习了Chart控件的初步使用方法,生成柱形图和饼图。

       <asp:Chart ID="Chart1" runat="server" Width="553px" Height="403px">
                <Series>
                    <asp:Series LegendText="得票数" Name="Series1" IsValueShownAsLabel="True" XValueMember="选择项"
                        YValueMembers="数量" Legend="Legend1" Color="Red" Font="Microsoft Sans Serif, 12pt"
                        LabelForeColor="Green">
                    </asp:Series>
                    <asp:Series ChartArea="ChartArea2" ChartType="Pie" Legend="Legend2" 
                        Name="Series2" IsValueShownAsLabel="True" XValueMember="选择项"
                        YValueMembers="数量" XValueType="String">
                    </asp:Series>
                </Series>
                <ChartAreas>
                    <asp:ChartArea Name="ChartArea1">
                        <AxisY Title="得票数">
                            <LabelStyle ForeColor="Blue" />
                        </AxisY>
                        <AxisX Title="课程">
                            <MajorGrid LineColor="Yellow" />
                            <%--线条颜色--%>
                        </AxisX>
                    </asp:ChartArea>
                    <asp:ChartArea Name="ChartArea2">
                        <AxisY Title="得票数">
                            <LabelStyle ForeColor="Blue" />
                        </AxisY>
                        <AxisX Title="课程">
                            <MajorGrid LineColor="Yellow" />
                            <%--线条颜色--%>
                        </AxisX>
                    </asp:ChartArea>
                </ChartAreas>
                <Legends>
                    <asp:Legend Name="Legend1">
                    </asp:Legend>
                    <asp:Legend Name="Legend2">
                    <Position X="80" Y="50" Height="20" Width="30" />
                    </asp:Legend>
                </Legends>
                <Titles>
                    <asp:Title Name="Title1" Text="投票结果">
                    </asp:Title>
                </Titles>
            </asp:Chart>
    后台代码:
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
     
                    Chart1.DataSource = GetTable();
    //#XVAL表示数据点的X值,#YVAL表示数据点的Y值                 Chart1.Series[1].Label = "课程:#VALX,得票数:#VALY";
    //显示在饼图外面                 Chart1.Series[1].CustomProperties = "PieLabelStyle=Outside";                 Chart1.Series[1].LabelToolTip = "#VALX: #VALY";
    //自定义图例                 Chart1.Series[1].LegendText = "#VALX";                              }         }         public DataTable GetTable()         {             string collectionstring = @"Data Source=.sqlexpress;Initial Catalog=OnlineVoteDB;User ID=sa;Pwd=xx;Persist Security Info=True;";              SqlConnection conn = new SqlConnection(collectionstring);             SqlDataAdapter sad = new SqlDataAdapter("select name as 选择项,votecount as 数量 from [Items] where [SubjectID]=13 ", conn);             DataSet ds = new DataSet();             sad.Fill(ds, "table"); conn.Close();             return ds.Tables[0];         }     }
    效果:

    
    
  • 相关阅读:
    开发流程
    团队模式
    android studio 中点击button加1或者减1
    登录注册界面的测试点
    用在线工具processOn画UML的用例图和时序图
    android studio中R文件丢失了
    第一次迭代任务
    WBS(work Breakdown Structure)
    #“速达” app NABCD分析
    “速达”app电梯演说
  • 原文地址:https://www.cnblogs.com/zhouhb/p/4241149.html
Copyright © 2011-2022 走看看