如何使用月份名称标记asp.net图表中的每个栏

时间:2015-08-17 12:25:48

标签: asp.net asp.net-mvc charts

我有以下图表输出和生成它的代码部分。 IsLabelAutofit = false但仍未显示所有月份标签。

<asp:Series Name="Series1" XValueMember="xDate" YValueMembers="TimePerDay"    ChartArea="ChartArea2" ChartType="column" YValuesPerPoint="6" IsValueShownAsLabel="true" LabelFormat="{0:N0}" >
                    </asp:Series>
                </Series>
                <ChartAreas>
                    <asp:ChartArea Name="ChartArea2">
                        <AxisY Interval="450">
                            <MajorGrid Enabled="true" LineColor="lightgray" />
                            <StripLines>
                                <asp:StripLine TextAlignment="Near" BorderDashStyle="Solid" BorderColor="#0000ff" BorderWidth="2" BackColor="#0000ff" />
                                <asp:StripLine BorderWidth="5" />
                            </StripLines>
                        </AxisY>
                        <AxisX IsLabelAutoFit="false" TitleForeColor="black">
                            <LabelStyle Format="MMMM" Angle="-90" IsEndLabelVisible="true" />


                            <MajorGrid Enabled="false" />
                        </AxisX>
                    </asp:ChartArea>
                </ChartAreas>

            </asp:Chart>

enter image description here

1 个答案:

答案 0 :(得分:1)

添加IntervalIntervalType,如下所示:

        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
                <AxisX IsLabelAutoFit="False">
                    <MajorTickMark Interval="1" IntervalType="Months" />
                    <LabelStyle Angle="-90" Format="MMMM" Interval="1" IntervalType="Months" />
                </AxisX>
            </asp:ChartArea>
        </ChartAreas>

结果:

enter image description here