Example #1
0
        private static void SetUpYAxis(BasicChart d)
        {
            var MyClass = (BasicChart)d;

            // Only calcualte the min and max values if AutoScale is true
            if (MyClass.AutoScale)
            {
                double TempYMax, TempYMin;
                TempYMax = double.MinValue;
                TempYMin = double.MaxValue;

                if (MyClass.ItemsSource == null)
                {
                    return;
                }
                foreach (var ClassItem in MyClass.ItemsSource)
                {
                    IEnumerable MyCollectionItem = (IEnumerable)GetPropValue(ClassItem, MyClass.DataCollectionName);
                    foreach (var item in MyCollectionItem)
                    {
                        double value = (double)GetPropValue(item, MyClass.DisplayMemberValues);
                        if (value < TempYMin)
                        {
                            TempYMin = value;
                        }

                        if (value > TempYMax)
                        {
                            TempYMax = value;
                        }
                    }
                }

                MyClass.YMax = TempYMax + (TempYMax - TempYMin) * 0.05d;
                MyClass.YMin = TempYMin - (TempYMax - TempYMin) * 0.05d;
            }

            MyClass.YItems = new ObservableCollection <YAxisLabels>();

            double deltaY = (MyClass.YMax - MyClass.YMin) / (MyClass.NumberOfYSteps);

            for (int j = 0; j <= MyClass.NumberOfYSteps; j++)
            {
                var YLabelObject = new YAxisLabels();
                YLabelObject.YLabel    = (MyClass.YMin + (double)j * deltaY).ToString(MyClass.DoubleToString);
                YLabelObject.YLocation = ((double)j) * (double)MyClass.PlotHeight / (double)MyClass.NumberOfYSteps;
                MyClass.YItems.Add(YLabelObject);
            }
        }