Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showing all values in chart control Xaxis

Tags:

vb.net

mschart

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
like image 929
dinotom Avatar asked May 23 '12 01:05

dinotom


1 Answers

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

like image 80
Frank_Vr Avatar answered Dec 04 '22 21:12

Frank_Vr