showing all values in chart control Xaxis

dinotom picture dinotom · May 23, 2012 · Viewed 20.4k times · Source

I have a chart of a bunch of products, 35 in all. They scale up the X Axis. The chart plots fine but only 5 of the product names show and I need them all to show. I have enabled MinorTickMark to true so all the tick marks show but how do i get their respective label to be visible?

I couldn't get the image to post so here is the aspx markup and the code behind. .aspx markup;

<asp:Chart ID="MonthinYearchart" Width="350px" Height="420px" runat="server">
            <Series> 
            <asp:Series  ChartType="Bar"  ChartArea="MainChartArea" Name="PnL"> 

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

Here is the code behind to put sample data in the chart.

Private Sub AllCommodforMonthChart()
    Dim cht As Chart = MonthinYearchart
    'create the arraylist of data
    'this is hardcoded to get chart to work, you will have to
    'set up the code to retrieve it from database
    Dim list As List(Of String) = GetList("Futures Data")
    Const val As Integer = 65

    'create all the data points
    For i As Integer = 0 To list.Count - 1
        cht.Series("PnL").Points.AddXY(list(i), val * i)
    Next
    cht.Series("PnL").ChartType = SeriesChartType.Bar
    cht.ChartAreas("MainChartArea").AxisX.MinorTickMark.Enabled = True

End Sub

Answer

Frank_Vr picture Frank_Vr · Mar 27, 2014

chart control is very limited, if you want to customize it, you are better of creating your own chart, by generating an image:

see link