0

我已经制作了一个 asp.net 图表,其中包含一些来自 DB 的 x 轴和 y 轴数据,如下所示。

在此处输入图像描述

现在我想用这样的月份附加一个自定义值 Current DECDay

在此处输入图像描述

请任何人告诉我如何实现这一点。请帮助!这是我的图表代码

<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource11" Compression="5"
                                                BackImageAlignment="Top" Palette="None" Width="400px" Height="250px">
                                                <Series>
                                                    <asp:Series Name="2011-12" XValueMember="MON" YValueMembers="CRSH_11_12" ChartType="Spline"
                                                        YValuesPerPoint="2" IsXValueIndexed="True" MarkerSize="7" MarkerStyle="Square"
                                                        ChartArea="ChartArea1" LabelFormat="#,###,###" Color="Black" YValueType="Double"
                                                        Legend="Legend1" LegendToolTip="#TOTAL{#,###,###,###}">
                                                        <EmptyPointStyle LabelFormat="#,###,###" />
                                                    </asp:Series>
                                                    <asp:Series Name="2012-13" XValueMember="MON" YValueMembers="CRSH_12_13" ChartType="Spline"
                                                        YValuesPerPoint="2" IsXValueIndexed="True" MarkerSize="7" MarkerStyle="Diamond"
                                                        ChartArea="ChartArea1" LabelFormat="#,###,###" Color="0, 192, 0" YValueType="Double"
                                                        Legend="Legend1" LegendToolTip="#TOTAL{#,###,###,###}">
                                                        <EmptyPointStyle LabelFormat="#,###,###" />
                                                    </asp:Series>
                                                    <asp:Series Name="Target" XValueMember="MON" YValueMembers="CAN_TRG" ChartType="Spline"
                                                        YValuesPerPoint="2" IsXValueIndexed="True" MarkerSize="7" MarkerStyle="Triangle"
                                                        ChartArea="ChartArea1" LabelFormat="#,###,###" Color="Blue" YValueType="Double"
                                                        Legend="Legend1" LegendToolTip="#TOTAL{#,###,###,###}">
                                                        <EmptyPointStyle LabelFormat="#,###,###" />
                                                    </asp:Series>
                                                    <asp:Series Name="Todate" XValueMember="MON" YValueMembers="YTD_CRSH" ChartType="Spline" BorderWidth="1"
                                                        YValuesPerPoint="2" IsXValueIndexed="True" MarkerStyle="None"
                                                        ChartArea="ChartArea1" Color="Red" YValueType="Double"
                                                        Legend="Legend1" >

                                                    </asp:Series>
                                                </Series>
                                                <ChartAreas>
                                                    <asp:ChartArea Name="ChartArea1" AlignmentOrientation="All">
                                                        <AxisY Title="Crushing (MT)" TitleForeColor="3, 91, 172" TitleFont="Arial, 8.25pt">
                                                            <MajorGrid LineColor="217, 239, 253" />
                                                            <LabelStyle Format="#,###,###" />
                                                        </AxisY>
                                                        <AxisX LineColor="Maroon" TitleFont="Tahoma, 8pt" Title="Month" TitleForeColor="3, 91, 172">
                                                            <MajorGrid LineColor="217, 239, 253" />
                                                        </AxisX>
                                                    </asp:ChartArea>
                                                </ChartAreas>
                                                <Legends>
                                                    <asp:Legend Alignment="Far" Docking="Bottom" Name="Legend1">
                                                    </asp:Legend>
                                                </Legends>
                                                <Titles>
                                                    <asp:Title Font="Microsoft Sans Serif, 10pt, style=Bold" ForeColor="3, 91, 172" Name="Title1"
                                                        Text="Crushing">
                                                    </asp:Title>
                                                </Titles>
                                            </asp:Chart>
4

1 回答 1

0

处理控制Customize事件Chart

private void chart1_Customize(object sender, EventArgs e)
{
    foreach (var xAxisLabel in chart1.ChartAreas[0].AxisX.CustomLabels)
    {
        if (// xAxisLabel is Dec)
            label.Text = xAxisLabel + /*custom day*/;
    }
}
于 2013-07-28T08:57:28.890 回答