showing all values in chart control Xaxis

前端 未结 2 653
轻奢々
轻奢々 2021-01-12 00:53

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 ena

2条回答
  •  终归单人心
    2021-01-12 01:34

    The answer lies in the Axis LabelStyles. The code below will format the axis (X or Y) so that all minor tick marks show, the interval is one and all the labels for each tickmark will show.

     cht.ChartAreas("MainChartArea").AxisX.MinorTickMark.Enabled = True
    cht.ChartAreas("MainChartArea").AxisX.Interval = 1
    cht.ChartAreas("MainChartArea").AxisX.IsLabelAutoFit = True
    'cht.ChartAreas("MainChartArea").AxisX.LabelStyle.IsStaggered = True
    cht.ChartAreas("MainChartArea").AxisX.LabelAutoFitStyle =  LabelAutoFitStyles.DecreaseFont
    

    Note: If you want the labels staggered then uncomment out the next to last line

提交回复
热议问题