15

I have a problem with an MS Chart chart type column. If there are more than 9 bars in the chart, the axis-x labels won't show up properly, some of them just disappear.

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>

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

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153
Tola
  • 2,401
  • 10
  • 36
  • 60

4 Answers4

34

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
  • 356
  • 2
  • 2
3

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

Ranjan
  • 51
  • 1
2
<ChartAreas>
<asp:ChartArea Name="ChartArea1" >
<AxisY Title="Progress->">
</AxisY>
<AxisX Interval="1" Title="Activity->">
</AxisX>
</asp:ChartArea>
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Ranjan
  • 51
  • 1
0

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
  • 1,175
  • 1
  • 12
  • 24
  • 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. – Tola Mar 12 '10 at 20:25
  • Try adding one more DataPoint to the end of the list like this. – mhinton Mar 12 '10 at 21:07
  • 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. – Tola Mar 13 '10 at 06:01