views:

2605

answers:

5

Hi,

I'm having problem with MS Chart chart type column. If there are only 9 bar in the chart like the following picture, then the axis-x label show up properly.

alt text

However, there are more than 9 bars bar the chart, the axis-x label wont show up properly, some of them just dissappear.

alt text

Here's my mark-up for the chart:

    <asp:Chart ID="chtNBAChampionships" runat="server">
   <Series>
      <asp:Series Name="Championships" YValueType="Int32" Palette="Berry"   ChartType="Column" ChartArea="MainChartArea" IsValueShownAsLabel="true">
         <Points>
            <asp:DataPoint AxisLabel="Celtics" YValues="17" />
            <asp:DataPoint AxisLabel="Lakers" YValues="15" />
            <asp:DataPoint AxisLabel="Bulls" YValues="6" />
            <asp:DataPoint AxisLabel="Spurs" YValues="4" />
            <asp:DataPoint AxisLabel="76ers" YValues="3" />
            <asp:DataPoint AxisLabel="Pistons" YValues="3" />
            <asp:DataPoint AxisLabel="Warriors" YValues="3" />
            <asp:DataPoint AxisLabel="Mara" YValues="4" />
            <asp:DataPoint AxisLabel="Saza" YValues="9" />
            <asp:DataPoint AxisLabel="Buha" YValues="6" />

         </Points>
      </asp:Series>
   </Series>
   <ChartAreas>
      <asp:ChartArea Name="MainChartArea">
      </asp:ChartArea>
   </ChartAreas>
</asp:Chart>

I don't know it works with only 9 bars? Is there any way to make the chart work properly? Also, if possible, how to make each bar have different color. Thank you.

A: 

Try setting the width of the chart and see if that resolves issue with only showing 9 bars.

<asp:Chart ID="chtNBAChampionships" runat="server" Width="400px">

You can set the color in the DataPoint.

<asp:DataPoint AxisLabel="Celtics" YValues="17" Color="Green" />
MHinton
MHinton, the Width trick doesn't work. I even set Width="800px" Height="600px" to see the change but the AxisLabel won't show up properly. The same problem arises.
Angkor Wat
Try adding one more DataPoint to the end of the list like this. <asp:DataPoint AxisLabel="" YValues="0" />
MHinton
The result is still the same. AxisLabel won't show up properly. Intead of showing 10 AxisLabel, it shows only 5 like the 2nd picture above.
Angkor Wat
+4  A: 

I had the same problem, but i'm using c# on page load.

I solved it by adding this

    Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;
Barry yrrab
A: 

Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;

Ranjan
A: 

"> ">

Ranjan
A: 

Thank you

Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;

Worked for me :),

was finding a solution for this from 2 days now, finally one line of code got it working for me

thank you once again

Developer_India