Пример #1
0
        protected override void SetupChart()
        {
            this.flexChart1.ChartType         = ChartType.RangedHistogram;
            this.flexChart1.Header.Content    = "Age Distribution";
            this.flexChart1.Header.Style.Font = StyleInfo.ChartHeaderFont;

            _rangedHistoSeries = new C1.Win.Chart.RangedHistogram()
            {
                Binding      = "Age",
                BinWidth     = 10,
                BinMode      = HistogramBinning.BinWidth,
                OverflowBin  = 150,
                UnderflowBin = 0,
            };
            this.flexChart1.Series.Add(_rangedHistoSeries);
            this.flexChart1.AxisX.Title           = "Age Groups";
            this.flexChart1.AxisX.TitleStyle.Font = StyleInfo.AxisTitleFont;
            this.flexChart1.AxisY.Title           = "Number Of Persons";
            this.flexChart1.AxisY.TitleStyle.Font = StyleInfo.AxisTitleFont;
            this.flexChart1.DataSource            = Demographics.GetAgeData();
            this.flexChart1.Rendered += FlexChart1_Rendered;
        }
Пример #2
0
        protected override void SetupChart()
        {
            this.flexChart1.Header.Content        = "Factors Influencing Purchase Decisions";
            this.flexChart1.Header.Style.Font     = StyleInfo.ChartHeaderFont;
            this.flexChart1.AxisY.Title           = "No. of Customers";
            this.flexChart1.AxisY.AxisLine        = true;
            this.flexChart1.AxisY.TitleStyle.Font = StyleInfo.AxisTitleFont;
            this.flexChart1.AxisX.Title           = "Factors";
            this.flexChart1.AxisX.TitleStyle.Font = StyleInfo.AxisTitleFont;
            this.flexChart1.ChartType             = ChartType.RangedHistogram;
            var histogram = new C1.Win.Chart.RangedHistogram()
            {
                Binding        = "Value",
                BindingX       = "Name",
                Name           = "Count",
                SortDescending = true,
                DataSource     = DataService.GetPurchaseFactorsData(),
                DataLabel      = new DataLabel {
                    Content = "{y:N0}", Position = LabelPosition.Top
                },
            };

            this.flexChart1.Series.Add(histogram);
            //calculate data for Pareto line
            var    histoYs       = histogram.GetValues(0);
            var    sum           = histoYs.Sum();
            var    paretoData    = new List <PointF>();
            double cumulativeSum = 0;

            for (int i = 0; i < histoYs.Length; i++)
            {
                cumulativeSum += histoYs[i];
                paretoData.Add(new PointF
                {
                    X = i,
                    Y = (float)(cumulativeSum / sum),
                });
            }
            var paretoLine = new Series
            {
                Name       = "Cumulative %",
                ChartType  = ChartType.LineSymbols,
                DataSource = paretoData,
                Binding    = "Y",
                BindingX   = "X",
                AxisY      = new Axis
                {
                    Position = Position.Right,
                    Min      = 0,
                    Max      = 1,
                    Format   = "P0",
                    Title    = "Cumulative Percentage",
                },
                DataLabel = new DataLabel {
                    Content = "{y:P2}", Position = LabelPosition.Top
                },
            };

            paretoLine.AxisY.TitleStyle.Font = StyleInfo.AxisTitleFont;
            paretoLine.Style.StrokeWidth     = paretoLine.SymbolStyle.StrokeWidth = 3;
            paretoLine.Style.StrokeColor     = paretoLine.SymbolStyle.FillColor = Color.FromArgb(255, 192, 80, 77);
            this.flexChart1.Series.Add(paretoLine);
            this.flexChart1.MouseMove += OnMouseMove;
        }