1

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

Dr. Mian
  • 3,334
  • 10
  • 45
  • 69

1 Answers1

1

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

jsanalytics
  • 13,058
  • 4
  • 22
  • 43
  • Thanks, you are almost there. The one small problem also visible in your chart is that there is no tick in front of other months. Is it possible to add them to the February, March, May, June, August, September, November and December? – Dr. Mian Aug 17 '15 at 17:11
  • Is there any thing for weekwise? I will post another question but just wana know. – Dr. Mian Aug 17 '15 at 20:40
  • Can you have a look of my question and give your suggestion please. http://stackoverflow.com/questions/32059936/how-to-label-the-weekly-chart-in-asp-net-chart-control – Dr. Mian Aug 17 '15 at 21:24
  • I don't have an immediate good suggestion. `DateTime` does not convert straight into a "week" value. You would have to use `Calendar` to do that calculation and get the week of the year. It is a bit more complicated because it involves culture information, leap year, what your convention is for the first day of the week, etc.... :O) – jsanalytics Aug 17 '15 at 22:08