How to fix problems with the X-Axis in Microsoft Charting Components - Digital Tool Factory blog How to fix problems with the X-Axis in Microsoft Charting Components - Digital Tool Factory blog

How to fix problems with the X-Axis in Microsoft Charting Components

The Problem: You’re creating a line or area chart using the Microsoft Charting components (the ones in System.Web.UI.DataVisualization.Charting, not System.Web.Helpers) and for whatever reason the first entry is actually in the second quadrant, like so:

The Cause: The charting components assume you want to show some sort of contrast for the first value, but it just doesn’t look right in this case.

The Solution: Set your minimum value to 1 instead of zero (zero is the default), like so

myChart.ChartAreas[0].AxisX.Minimum = 1;

The chart will now be pushed flush left, for a much better appearance.  You will see something like the chart below.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog

Tags:

 

Written By Steve French

 

Leave a Reply

Your email address will not be published. Required fields are marked *






Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.