如何在ASP.NET图表上显示值

时间:2013-07-04 20:35:41

标签: asp.net mschart

这是我的图表: enter image description here

ASP.NET代码:

<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1" Width="752px">
    <Series>
        <asp:Series Name="Series1" XValueMember="Column2" YValueMembers="Column1">
        </asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="ChartArea1" BorderColor="DarkGray">
        </asp:ChartArea>
    </ChartAreas>
</asp:Chart>

如何在蓝框上显示值?

1 个答案:

答案 0 :(得分:7)

您可以从代码隐藏中执行此操作:

Chart1.Series["Series1"].IsValueShownAsLabel = true;

您也可以从ASPX代码执行此操作:

<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1" Width="752px">
    <Series>
        <asp:Series Name="Series1" XValueMember="Column2" YValueMembers="Column1" IsValueShownAsLabel="true">
        </asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="ChartArea1" BorderColor="DarkGray">
        </asp:ChartArea>
    </ChartAreas>
</asp:Chart>