0

我正在尝试在 aspx 页面上绘制聊天。我用固定值的 ajaxtool 工具包绘制了图表。现在我想根据 SQL 服务器中存在的数据绘制图表。如何将数据与图表绑定?

<ajaxToolkit:LineChart ID="LineChart1" runat="server" 
    ChartWidth="450" ChartHeight="300" ChartType="Basic" 
    ChartTitle="x,y vs year" 
    CategoriesAxis="2007,2008,2009,2010,2011,2012" 
    ChartTitleColor="#0E426C" CategoryAxisLineColor="#D08AD9" 
    ValueAxisLineColor="#D08AD9" BaseLineColor="#A156AB">
    <Series>
        <ajaxToolkit:LineChartSeries Name="x" 
        LineColor="#6C1E83" Data="110, 189, 255, 95, 107, 140" />
        <ajaxToolkit:LineChartSeries Name="y"  
        LineColor="#D08AD9" Data="49, 77, 95, 68, 70, 79" />
    </Series>
    </ajaxToolkit:LineChart>
4

1 回答 1

0

您可以在代码隐藏(更多控制)中执行此操作,或者像这样:

<asp:Chart ID="MyChart" runat="server" DataSourceID="MySQLDataSource">
    <Series>
        <asp:Series Name="Series1" XValueMember="x" YValueMembers="y">
        </asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="ChartArea1">
        </asp:ChartArea>
    </ChartAreas>
</asp:Chart>
<asp:SqlDataSource ID="MsSQLDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
    SelectCommand="SELECT x, y FROM [MyTable]">
</asp:SqlDataSource>
于 2013-10-28T10:48:27.670 回答