0

I am using Microsoft's DataVisualization.Charting.Chart, and I have integer values along the X axis, using line-style graphs. However, the chart is adding an extra blank item at the beginning and end of the x-axis, with no value labels to explain what they are.

How can I remove these empty items and make the lines go right up to the ends?

Savage
  • 2,296
  • 2
  • 30
  • 40

2 Answers2

2

Use the IsMarginVisible property of the xaxis. I believe that will do the trick.

To test this, I changed one of my own charts to be a line chart and then set the value in the code:

ReactivityChart.ChartAreas(0).AxisX.IsMarginVisible = False

Tell me if this is what you were hoping to get or if I have totally misunderstood the question:

(note that I do not have a high enough rep to post this image)

http://www.rectorsquid.com/chartmargintest.gif

David Rector
  • 958
  • 9
  • 31
1

You should set the Maximum and Minimum properties in ChartArea.AxisX, e.g. :

this.chart1.ChartAreas[0].AxisX.Minimum = 0;   // if your minimum X = 0
this.chart1.ChartAreas[0].AxisX.Maximum = 100; // if your maximum X = 100

In this way, your chart area will show only the values between Minimum and Maximum.

digEmAll
  • 56,430
  • 9
  • 115
  • 140