简体   繁体   中英

Primary X axis in MS chart control wont display max value?

I am using MS chart control .net 4 framework in Visual studio 2010 using Windows forms. I am having an issue with the scale of the primary x axis on a user input from a text box on a button click. I am also using both the primary and secondary y axes which work on a user input.

I have checked the settings for each axis and they all have the same settings. I don't see why both y axes work on the user input and the x does not. Please help.

The following is the code I am using:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    Chart1.ChartAreas("Area1").AxisX.Minimum = Val(XPrimeMin.Text)
    Chart1.ChartAreas("Area1").AxisX.Maximum = Val(XPrimeMax.Text)
    Chart1.ChartAreas("Area1").AxisX.Interval = Val(XPrimeInterval.Text)
    Chart1.ChartAreas("Area1").AxisX.LabelStyle.Interval = Val(XPrimeInterval.Text)

    Chart1.ChartAreas("Area1").AxisY.Minimum = Val(YPrimeMin.Text)
    Chart1.ChartAreas("Area1").AxisY.Maximum = Val(YPrimeMax.Text)
    Chart1.ChartAreas("Area1").AxisY.Interval = Val(YPrimeInterval.Text)
    Chart1.ChartAreas("Area1").AxisY.LabelStyle.Interval = Val(YPrimeInterval.Text)

    Chart1.ChartAreas("Area1").AxisY2.Minimum = Val(YSecMin.Text)
    Chart1.ChartAreas("Area1").AxisY2.Maximum = Val(YSecMax.Text)
    Chart1.ChartAreas("Area1").AxisY2.Interval = Val(YSecInterval.Text)
    Chart1.ChartAreas("Area1").AxisY2.LabelStyle.Interval = Val(YSecInterval.Text)

End Sub

This is a screen shot of what I get while on auto-scale:

在此处输入图像描述

This is after I set the Axes by user input:

在此处输入图像描述

The solution that worked for me was to convert the value I was taking from the array to a double value before adding it to the series data point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM