J-P
J-P

Reputation: 403

Not all my X axis label are showing when there is a lot of data C# WinForms

I have a chart that prints for me a chart of exception data, and label each exception type, when I run it with many data the chart only shows 3 labels, when I reduce the amount of type of exception the text starts to appear on some of them till I reduce more and all of them will be labeled

I used the following chartArea code:

 reportChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new Font("Ariel",7F);
 reportChart.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.WordWrap;

Is there a way that I can wrap the text which will be small enough to label the data and readable? Chart

Update here is how i build the chart:

private void BuildChart()
    {
        int count = 0;
        Random random = new Random();
        foreach (KeyValuePair<string, int> exception in Messages)
        {
            int red = random.Next(0, 255);
            int green = random.Next(0, 255);
            int blue = random.Next(0, 255);
            if (exception.Value > int.Parse(thresholdTxb.Text))
            {
                reportChart.Series[0].Points.AddXY(exception.Key, exception.Value);
                reportChart.Series[0].Points[count].Color = Color.FromArgb(red, blue, green);
                count++;
            }
        }
    }

Any idea why?

Upvotes: 1

Views: 2363

Answers (1)

jsanalytics
jsanalytics

Reputation: 13188

Make:

 chart1.ChartAreas[0].AxisX.LabelStyle.Angle = -90;
 chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1;

enter image description here

Upvotes: 2

Related Questions