Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Automatic AxisRangeType bug with negative numbers
posted

Using a composite chart, ScatterChart layer, when using an axis with AutoRangeType = Automatic, the range gets all screwed up if you use negative numbers, and it seems like they closer the negative numbers are in value, the more it gets screwed up, until you get no range at all (max is less than min).  (Incidentally, If you remove the negative signs, you get real range values, but they are way too big, like they are based on the size of the values (~6800), instead of the difference between the min and max values (~8), but that's better than nothing at all.)

To reproduce, use the below code, and muck with the Y Values in minPoint and maxPoint to see what I mean.  I added in a click event to show that the actual window values are completely messed up.

Using v10.3, drag chart onto form.  Use this code in the Form:

      private ChartLayerAppearance chartLayer;

     

      public Form1()

      {

         InitializeComponent();

 

         ultraChart4.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite;

         ChartArea chartArea = new ChartArea();

         ultraChart4.CompositeChart.ChartAreas.Add(chartArea);

         chartArea.Border.Color = Color.Transparent;

 

         var xAxis = CreateAxis(AxisNumber.X_Axis, AxisDataType.Numeric, NumericAxisType.Linear, "<DATA_VALUE:0.###>", TextOrientation.Horizontal);

         var yAxis = CreateAxis(AxisNumber.Y_Axis, AxisDataType.Numeric, NumericAxisType.Linear, "<DATA_VALUE:0.###>", TextOrientation.Horizontal);

         chartLayer = CreateChartLayer(ChartType.ScatterChart, xAxis, yAxis);

 

         XYSeries series = new XYSeries();

         chartLayer.Series.Clear();

         chartLayer.Series.Add(series);

         ultraChart4.CompositeChart.Series.Add(series);

 

         XYDataPoint minPoint = new XYDataPoint(112.998893799, -6899.666666667, "Min", false);

         XYDataPoint maxPoint = new XYDataPoint(147.542366667, -6891.333333333, "Max", false);

 

         series.Points.Clear();

         series.Points.Add(minPoint);

         series.Points.Add(maxPoint);

 

      }

 

      private void ultraChart4_Click(object sender, EventArgs e)

      {

         IAdvanceAxis axisY = (IAdvanceAxis)chartLayer.ChartLayer.Grid["Y"];

         var yAxisMin = axisY.WindowMinimum;

         var yAxisMax = axisY.WindowMaximum;

 

         MessageBox.Show("Min is bigger than max??\n\nMin: " + yAxisMin + "\nMax: " + yAxisMax, "What's up with this?", MessageBoxButtons.OK, MessageBoxIcon.Question);

      }

 

      private ChartLayerAppearance CreateChartLayer(ChartType chartType, AxisItem axisX, AxisItem axisY)

      {

         ChartLayerAppearance newLayer = new ChartLayerAppearance();

         newLayer.ChartType = chartType;

         newLayer.ChartArea = ultraChart4.CompositeChart.ChartAreas[0];

         newLayer.AxisX = axisX;

         newLayer.AxisY = axisY;

         ultraChart4.CompositeChart.ChartLayers.Add(newLayer);

         return newLayer;

      }

 

      private AxisItem CreateAxis(AxisNumber orientationType, AxisDataType dataType, NumericAxisType numericAxisType, string itemFormatString, TextOrientation textOrientation)

      {

         AxisItem newAxis = new AxisItem();

         newAxis.OrientationType = orientationType;

         newAxis.DataType = dataType;

         newAxis.NumericAxisType = numericAxisType;

         newAxis.Labels.ItemFormatString = itemFormatString;

         newAxis.Labels.Orientation = textOrientation;

         newAxis.TickmarkStyle = AxisTickStyle.Smart;

         newAxis.RangeType = AxisRangeType.Automatic;

         newAxis.LineThickness = 1;

         newAxis.LineColor = Color.Black;

         newAxis.MajorGridLines.Color = Color.Gray;

         newAxis.MinorGridLines.Visible = true;

         newAxis.MinorGridLines.Visible = false;

         newAxis.Extent = 25;

         newAxis.LogZero = 1;

         newAxis.Labels.HorizontalAlign = StringAlignment.Near;

         newAxis.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.None;

         newAxis.Labels.Layout.Padding = 5;

         ultraChart4.CompositeChart.ChartAreas[0].Axes.Add(newAxis);

         return newAxis;

      }