ChartAreas(0).AxisX.LabelStyle.Format Is changing my Axis label Text instead of my format
So I'm starting to play with the Microsoft Chart control for the first time and I ran into an issue.
I'm returning a database query into a List object and using that list object to fill the X and Y axes of my chart as seen below. (_runData is a "List(of DatabaseTableName)" style Object filled with the results of my query.
Primary_Chart.Series(0).Points.DataBindXY(_runData, "DateTime", _runData, "UPPER_PRESSURE")
My Datetime field is returning as a Serial Number (i.e. 40116.76111) so I want to format the X Axis to display the field more readably. Enter my problem code.
Chart_Obj.ChartAreas(0).AxisX.LabelStyle.Format = "MM"
This code changes my axis to display MM instead of the Serial Number. I have experimented with other Formatting type and the result is that my Axis Labels change to read exactly as whatever I put a开发者_如何学Cfter the = sign.
What am I missing here? Thanks a ton.
You need to set the XValueType on the series to DateTime or Date so that the charts know to display the values as datetimes rather than doubles.
Primary_Chart.Series(0).XValueType = ChartValueType.DateTime
For more details see http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.series.xvaluetype.aspx
精彩评论