Exemplo n.º 1
0
        protected override void Scale()
        {
            PrimaryAxis.MinValue = 0;

            var stackedSeries = Series.OfType <StackedBarSeries>().ToList();
            var fSerie        = stackedSeries.FirstOrDefault();

            if (fSerie == null)
            {
                return;
            }
            for (var i = 0; i < fSerie.PrimaryValues.Count; i++)
            {
                var helper = new StackedBarHelper();
                var sum    = 0d;
                for (int index = 0; index < stackedSeries.Count; index++)
                {
                    var serie = stackedSeries[index];
                    var value = serie.PrimaryValues.Any() ? serie.PrimaryValues[i] : double.MinValue;
                    helper.Stacked[index] = new StackedItem
                    {
                        Value   = value,
                        Stacked = sum
                    };
                    sum += value;
                }
                helper.Total   = sum;
                IndexTotals[i] = helper;
            }

            Max = GetMax();
            Min = GetMin();
            S   = GetS();

            Max.Y = PrimaryAxis.MaxValue ?? (Math.Truncate(Max.Y / S.Y) + 1) * S.Y;
            Min.Y = PrimaryAxis.MinValue ?? (Math.Truncate(Min.Y / S.Y) - 1) * S.Y;

            DrawAxis();
        }
Exemplo n.º 2
0
        protected override void Scale()
        {
            foreach (var series in Series)
            {
                series.Collection = Series;
                if (series.Values == null) continue;
                series.Values.Series = series;
                series.Values.Evaluate();
            }

            AxisY.MinValue = 0;

            var stackedSeries = Series.OfType<StackedBarSeries>().ToList();
            var fSerie = stackedSeries.FirstOrDefault();
            if (fSerie == null) return;
            for (var i = 0; i < fSerie.Values.Count; i++)
            {
                var helper = new StackedBarHelper();
                var sum = 0d;
                for (int index = 0; index < stackedSeries.Count; index++)
                {
                    var serie = stackedSeries[index];
                    var value = serie.Values.Points.Any()
                        ? (serie.Values.Points as IList<ChartPoint>)[i].Y
                        : double.MinValue;
                    helper.Stacked[index] = new StackedItem
                    {
                        Value = value,
                        Stacked = sum
                    };
                    sum += value;
                }
                helper.Total = sum;
                IndexTotals[i] = helper;
            }

            Max = GetMax();
            Min = GetMin();
            S = GetS();

            Max.Y = AxisY.MaxValue ?? (Math.Truncate(Max.Y / S.Y) + 1) * S.Y;
            Min.Y = AxisY.MinValue ?? (Math.Truncate(Min.Y / S.Y) - 1) * S.Y;

            DrawAxes();
        }
Exemplo n.º 3
0
        protected override void Scale()
        {
            PrimaryAxis.MinValue = 0;

            var stackedSeries = Series.OfType<StackedBarSeries>().ToList();
            var fSerie = stackedSeries.FirstOrDefault();
            if (fSerie == null) return;
            for (var i = 0; i < fSerie.PrimaryValues.Count; i++)
            {
                var helper = new StackedBarHelper();
                var sum = 0d;
                for (int index = 0; index < stackedSeries.Count; index++)
                {
                    var serie = stackedSeries[index];
	                var value = serie.PrimaryValues.Any() ? serie.PrimaryValues[i] : double.MinValue;
                    helper.Stacked[index] = new StackedItem
                    {
                        Value = value,
                        Stacked = sum
                    };
                    sum += value;
                }
                helper.Total = sum;
                IndexTotals[i] = helper;
            }

            Max = GetMax();
            Min = GetMin();
            S = GetS();

            Max.Y = PrimaryAxis.MaxValue ?? (Math.Truncate(Max.Y / S.Y) + 1) * S.Y;
            Min.Y = PrimaryAxis.MinValue ?? (Math.Truncate(Min.Y / S.Y) - 1) * S.Y;

            DrawAxis();
        }
Exemplo n.º 4
0
        protected override void Scale()
        {
            InitializeComponents();

            if (!HasValidSeriesAndValues) return;

            if (Invert) AxisX.MinValue = 0;
            else AxisY.MinValue = 0;

            var stackedSeries = Series.OfType<StackedBarSeries>().ToList();
            //All series must have the same number of items.
            var fSerie = stackedSeries.FirstOrDefault();
            if (fSerie == null) return;
            for (var i = 0; i < fSerie.Values.Count; i++)
            {
                var helper = new StackedBarHelper();
                var sum = 0d;
                for (int index = 0; index < stackedSeries.Count; index++)
                {
                    var serie = stackedSeries[index];
                    var p = (serie.Values.Points as IList<ChartPoint>)[i];
                    var value = serie.Values.Points.Any()
                        ? (Invert ? p.X : p.Y)
                        : double.MinValue;
                    helper.Stacked[index] = new StackedItem
                    {
                        Value = value,
                        Stacked = sum
                    };
                    sum += value;
                }
                helper.Total = sum;
                IndexTotals[i] = helper;
            }

            Max = GetMax();
            Min = GetMin();
            S = GetS();

            if (Invert)
            {
                Max.X = AxisX.MaxValue ?? (Math.Truncate(Max.X / S.X) + 1) * S.X;
                Min.X = AxisX.MinValue ?? (Math.Truncate(Min.X / S.X) - 1) * S.X;
            }
            else
            {
                Max.Y = AxisY.MaxValue ?? (Math.Truncate(Max.Y / S.Y) + 1) * S.Y;
                Min.Y = AxisY.MinValue ?? (Math.Truncate(Min.Y / S.Y) - 1) * S.Y;
            }

            DrawAxes();
        }
Exemplo n.º 5
0
        protected override void Scale()
        {
            InitializeComponents();

            if (!HasValidSeriesAndValues)
            {
                return;
            }

            if (Invert)
            {
                AxisX.MinValue = 0;
            }
            else
            {
                AxisY.MinValue = 0;
            }

            var stackedSeries = Series.OfType <StackedBarSeries>().ToList();
            //All series must have the same number of items.
            var fSerie = stackedSeries.FirstOrDefault();

            if (fSerie == null)
            {
                return;
            }
            for (var i = 0; i < fSerie.Values.Count; i++)
            {
                var helper = new StackedBarHelper();
                var sum    = 0d;
                for (int index = 0; index < stackedSeries.Count; index++)
                {
                    var serie = stackedSeries[index];
                    var p     = (serie.Values.Points as IList <ChartPoint>)[i];
                    var value = serie.Values.Points.Any()
                        ? (Invert ? p.X : p.Y)
                        : double.MinValue;
                    helper.Stacked[index] = new StackedItem
                    {
                        Value   = value,
                        Stacked = sum
                    };
                    sum += value;
                }
                helper.Total   = sum;
                IndexTotals[i] = helper;
            }

            Max = GetMax();
            Min = GetMin();
            S   = GetS();

            if (Invert)
            {
                Max.X = AxisX.MaxValue ?? (Math.Truncate(Max.X / S.X) + 1) * S.X;
                Min.X = AxisX.MinValue ?? (Math.Truncate(Min.X / S.X) - 1) * S.X;
            }
            else
            {
                Max.Y = AxisY.MaxValue ?? (Math.Truncate(Max.Y / S.Y) + 1) * S.Y;
                Min.Y = AxisY.MinValue ?? (Math.Truncate(Min.Y / S.Y) - 1) * S.Y;
            }

            DrawAxes();
        }
Exemplo n.º 6
0
        protected override void PrepareAxes()
        {
            InitializeComponents();

            if (!HasValidSeriesAndValues)
            {
                return;
            }

            if (Invert)
            {
                foreach (var xi in AxisX)
                {
                    xi.MinValue = 0;
                }
            }
            else
            {
                foreach (var yi in AxisY)
                {
                    yi.MinValue = 0;
                }
            }

            var stackedSeries = Series.OfType <StackedBarSeries>().ToList();

            //All series must have the same number of items.
            //This chart should be kinf of buggy when adding mutiple axes.
            //ToDo: Review stacked bar chart and multiple axes
            //since the chart has only a StackedBarHelper,
            //then the escale of all axis mut be shared by this class,
            //one possible solution is to add a StackedBarHelper for each axis.
            //For now it is not safe to use multiple axis with stackedbar chart
            //unless the other axis do not contain StackedBarSeries.
            var fSerie = stackedSeries.FirstOrDefault();

            if (fSerie == null)
            {
                return;
            }
            for (var i = 0; i < fSerie.Values.Count; i++)
            {
                var helper = new StackedBarHelper();
                var sum    = 0d;
                for (int index = 0; index < stackedSeries.Count; index++)
                {
                    var serie = stackedSeries[index];
                    var p     = (serie.Values.Points as IList <ChartPoint>)[i];
                    var value = serie.Values.Points.Any()
                        ? (Invert ? p.X : p.Y)
                        : double.MinValue;
                    helper.Stacked[index] = new StackedItem
                    {
                        Value   = value,
                        Stacked = sum
                    };
                    sum += value;
                }
                helper.Total   = sum;
                IndexTotals[i] = helper;
            }

            //Max = GetMax();
            //Min = GetMin();
            //S = GetS();

            //if (Invert)
            //{
            //   AxisX.MaxLimit = AxisX.MaxValue ?? (Math.Truncate(Max.X /AxisX.S) + 1) *AxisX.S;
            //   AxisX.MinLimit = AxisX.MinValue ?? (Math.Truncate(Min.X /AxisX.S) - 1) *AxisX.S;
            //}
            //else
            //{
            //   AxisY.MaxLimit = AxisY.MaxValue ?? (Math.Truncate(Max.Y /AxisY.S) + 1) *AxisY.S;
            //   AxisY.MinLimit = AxisY.MinValue ?? (Math.Truncate(Min.Y /AxisY.S) - 1) *AxisY.S;
            //}

            CalculateComponentsAndMargin();
        }