drmaa
drmaa

Reputation: 3674

How to label each bar in asp.net chart with month name

I have the following chart output and the part of code to generate it. IsLabelAutofit=false but still it is not showing all the months label.

<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

Upvotes: 1

Views: 1532

Answers (1)

jsanalytics
jsanalytics

Reputation: 13188

Add Interval and IntervalType as shown below:

        <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>

Result:

enter image description here

Upvotes: 1

Related Questions