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

About the author

Steve French Steve is the President and lead developer of Digital Tool Factory and currently provides all technical development for DTF. Digital Tool Factory has provided behind the scenes technical muscle to the Atlanta design community since 2002.Google+ Profile

 

Written By Steve French

 

Leave a Reply





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