Пример #1
0
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Header.Text   = "Nearest Tool Directions";

            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);

            tool1 = new NearestPoint(tChart1.Chart);
            tool2 = new NearestPoint(tChart1.Chart);

            vertAxis  = new Axis(false, false, tChart1.Chart);
            horizAxis = new Axis(true, false, tChart1.Chart);
            line      = new Line(tChart1.Chart);
            horizLine = new HorizLine(tChart1.Chart);

            tChart1.Axes.Custom.Add(vertAxis);
            tChart1.Axes.Custom.Add(horizAxis);

            tChart1.Axes.Left.StartPosition  = 0;
            tChart1.Axes.Left.EndPosition    = 45;
            vertAxis.StartPosition           = 55;
            vertAxis.EndPosition             = 100;
            tChart1.Axes.Bottom.Grid.Visible = false;

            line.HorizAxis             = HorizontalAxis.Custom;
            line.CustomHorizAxis       = horizAxis;
            line.VertAxis              = VerticalAxis.Left;
            horizAxis.PositionUnits    = PositionUnits.Percent;
            horizAxis.RelativePosition = 55;
            horizAxis.Grid.Visible     = false;

            horizLine.VertAxis       = VerticalAxis.Custom;
            horizLine.CustomVertAxis = vertAxis;
            horizLine.HorizAxis      = HorizontalAxis.Bottom;

            tool1.Series      = line;
            tool1.Direction   = NearestPointDirection.Horizontal;
            tool1.DrawLine    = false;
            tool1.Brush.Color = horizLine.Color;
            tool1.Size        = 5;
            tool1.Change     += new EventHandler(tool1_Change);
            tool2.Series      = horizLine;
            tool2.Direction   = NearestPointDirection.Vertical;
            tool2.DrawLine    = false;
            tool2.Brush.Color = line.Color;
            tool2.Size        = 5;
            tool2.Change     += new EventHandler(tool2_Change);

            horizLine.FillSampleValues();
            line.FillSampleValues();

            anno1          = new Annotation(tChart1.Chart);
            anno2          = new Annotation(tChart1.Chart);
            anno1.Position = AnnotationPositions.LeftTop;
            anno2.Position = AnnotationPositions.RightBottom;
            anno1.Active   = false;
            anno2.Active   = false;
        }
Пример #2
0
        private void ChartToCreate(String item)
        {
            List <String[]> originalData = ChartData();

            String[] dataPicker = new String[originalData.Count];

            for (int i = 0; i < originalData.Count; i++)
            {
                dataPicker[i] = originalData[i][1];
            }
            _customChart.ChartView.Chart.Series.RemoveAllSeries();

            var imageButton = ((((this.Children[0] as ContentPage).Content as ScrollView).Content as StackLayout).Children[1] as Grid).Children[2] as Button;

            switch (item)
            {
            case "AREA":
                Area area = new Area();
                area.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(area);
                _customChart.ImageSource = dataPicker[0];
                imageButton.ImageSource  = dataPicker[0];

                break;

                    #if !TEE_STD
            case "ARROW":
                Arrow arrow = new Arrow();
                arrow.FillSampleValues(10);
                _customChart.ChartView.Chart.Series.Add(arrow);
                _customChart.ImageSource = dataPicker[1];
                imageButton.ImageSource  = dataPicker[1];
                break;
#endif

            case "BAR":
                Bar bar = new Bar();
                bar.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(bar);
                _customChart.ImageSource = dataPicker[2];
                imageButton.ImageSource  = dataPicker[2];
                break;

                    #if !TEE_STD
            case "BARJOIN":
                BarJoin barjoin = new BarJoin();
                barjoin.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(barjoin);
                _customChart.ImageSource = dataPicker[3];
                imageButton.ImageSource  = dataPicker[3];
                break;

            case "BEZIER":
                Bezier bezier = new Bezier();
                bezier.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(bezier);
                _customChart.ImageSource = dataPicker[4];
                imageButton.ImageSource  = dataPicker[4];
                break;

            case "BOX":
                Box box = new Box();
                box.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(box);
                _customChart.ImageSource = dataPicker[5];
                imageButton.ImageSource  = dataPicker[5];
                break;
#endif
            case "BUBBLES":
                Bubble bubble = new Bubble();
                bubble.FillSampleValues(7);
                _customChart.ChartView.Chart.Series.Add(bubble);
                _customChart.ImageSource = dataPicker[6];
                imageButton.ImageSource  = dataPicker[6];
                break;

                    #if !TEE_STD
            case "CANDLE":
                Candle candle = new Candle();
                candle.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(candle);
                _customChart.ImageSource = dataPicker[7];
                imageButton.ImageSource  = dataPicker[7];
                break;

            case "CONTOUR":
                Contour countour = new Contour();
                countour.FillSampleValues(1);
                _customChart.ChartView.Chart.Series.Add(countour);
                _customChart.ImageSource = dataPicker[8];
                imageButton.ImageSource  = dataPicker[8];
                break;

            case "DARVAS":
                Darvas darvas = new Darvas();
                darvas.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(darvas);
                _customChart.ImageSource = dataPicker[9];
                imageButton.ImageSource  = dataPicker[9];
                break;
#endif
            case "DONUT":
                Donut donut = new Donut();
                donut.FillSampleValues(1);
                _customChart.ChartView.Chart.Series.Add(donut);
                _customChart.ImageSource = dataPicker[10];
                imageButton.ImageSource  = dataPicker[10];
                break;

                    #if !TEE_STD
            case "ERROR":
                Error error = new Error();
                error.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(error);
                _customChart.ImageSource = dataPicker[11];
                imageButton.ImageSource  = dataPicker[11];
                break;

            case "ERRORBAR":
                ErrorBar errorbar = new ErrorBar();
                errorbar.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(errorbar);
                _customChart.ImageSource = dataPicker[12];
                imageButton.ImageSource  = dataPicker[12];
                break;

            case "ERRORPOINT":
                ErrorPoint errorPoint = new ErrorPoint();
                errorPoint.FillSampleValues(7);
                _customChart.ChartView.Chart.Series.Add(errorPoint);
                _customChart.ImageSource = dataPicker[13];
                imageButton.ImageSource  = dataPicker[13];
                break;
#endif
            case "FASTLINE":
                FastLine fastLine = new FastLine();
                fastLine.FillSampleValues(2);
                _customChart.ChartView.Chart.Series.Add(fastLine);
                _customChart.ImageSource = dataPicker[14];
                imageButton.ImageSource  = dataPicker[14];
                break;

                    #if !TEE_STD
            case "HIGHLOW":
                HighLow highLow = new HighLow();
                highLow.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(highLow);
                _customChart.ImageSource = dataPicker[15];
                imageButton.ImageSource  = dataPicker[15];
                break;

            case "HISTOGRAM":
                Histogram histogram = new Histogram();
                histogram.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(histogram);
                _customChart.ImageSource = dataPicker[16];
                imageButton.ImageSource  = dataPicker[16];
                break;
#endif
            case "HORIZAREA":
                HorizArea horizArea = new HorizArea();
                horizArea.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizArea);
                _customChart.ImageSource = dataPicker[17];
                imageButton.ImageSource  = dataPicker[17];
                break;

            case "HORIZBAR":
                HorizBar horizBar = new HorizBar();
                horizBar.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizBar);
                _customChart.ImageSource = dataPicker[18];
                imageButton.ImageSource  = dataPicker[18];
                break;

            case "HORIZLINE":
                HorizLine horizLine = new HorizLine();
                horizLine.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizLine);
                _customChart.ImageSource = dataPicker[19];
                imageButton.ImageSource  = dataPicker[19];
                break;

                    #if !TEE_STD
            case "ISOSURFACE":
                IsoSurface isoSurface = new IsoSurface();
                isoSurface.FillSampleValues(10);
                _customChart.ChartView.Chart.Series.Add(isoSurface);
                _customChart.ImageSource = dataPicker[20];
                imageButton.ImageSource  = dataPicker[20];
                break;
#endif
            case "LINE":
                Line line = new Line();
                line.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(line);
                _customChart.ImageSource = dataPicker[21];
                imageButton.ImageSource  = dataPicker[21];
                break;

#if !TEE_STD
            case "LINEPOINT":
                LinePoint linePoint = new LinePoint();
                linePoint.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(linePoint);
                _customChart.ImageSource = dataPicker[22];
                imageButton.ImageSource  = dataPicker[22];
                break;
#endif
            case "PIE":
                Pie pie = new Pie();
                pie.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(pie);
                _customChart.ImageSource = dataPicker[23];
                imageButton.ImageSource  = dataPicker[23];
                break;

#if !TEE_STD
            case "SURFACE":
                Surface surface = new Surface();
                surface.FillSampleValues(10);
                //surface.
                _customChart.ChartView.Chart.Series.Add(surface);
                _customChart.ImageSource = dataPicker[24];
                imageButton.ImageSource  = dataPicker[24];
                break;

            case "TOWER":
                Tower tower = new Tower();
                tower.FillSampleValues(8);
                _customChart.ChartView.Chart.Series.Add(tower);
                _customChart.ImageSource = dataPicker[25];
                imageButton.ImageSource  = dataPicker[25];
                break;

            case "VOLUME":
                Volume volume = new Volume();
                volume.FillSampleValues(9);
                _customChart.ChartView.Chart.Series.Add(volume);
                _customChart.ImageSource = dataPicker[26];
                imageButton.ImageSource  = dataPicker[26];
                break;
#endif
            }

            _customChart.ChartView.Chart.Axes.Left.Automatic   = true;
            _customChart.ChartView.Chart.Axes.Bottom.Automatic = true;
        }
        // Constructor del "LineChart"
        public HorizontalLineChart(ChartView BaseChart)
        {
            // Variables
            line1                = new HorizLine();
            line2                = new HorizLine();
            var                  = new Variables.Variables();
            this.BaseChart       = BaseChart;
            tool_dataPointSelect = new DataPointSelection(BaseChart);

            // Modificación del "Chart" base
            BaseChart.Chart.ClickSeries   += null;
            BaseChart.Chart.Legend.Visible = true;
            BaseChart.Chart.Header.Text    = "Bear population in two forests";
            BaseChart.Chart.Series.Add(line1);
            BaseChart.Chart.Series.Add(line2);

            line1.Add(var.GetValorHorizLine1, var.GetValorHorizLineY, true);
            line2.Add(var.GetValorHorizLine2, var.GetValorHorizLineY, true);

            // Propiedades de la "line1"

            line1.LinePen.Width = 6;
            line1.LinePen.Color = var.GetPaletteBasic[0];

            line1.Pointer.Color          = var.GetPaletteBasic[0];
            line1.Pointer.InflateMargins = true;
            line1.Pointer.Visible        = true;
            line1.Pointer.HorizSize      = 11;
            line1.Pointer.VertSize       = 11;
            line1.Pointer.Pen.EndCap     = PenLineCap.Round;
            line1.Pointer.Pen.Color      = Color.White;
            line1.Pointer.Pen.Width      = 5;
            line1.Pointer.Style          = PointerStyles.Sphere;

            line1.SeriesColor         = var.GetPaletteBasic[0];
            line1.Chart.Zoom.Allow    = false;
            line1.Chart.Panning.Allow = ScrollModes.None;
            line1.LineHeight          = 25;
            line1.ClickableLine       = true;
            line1.ClickPointer       += tool_dataPointSelect.PointValue_Click;
            line1.GetSeriesMark      += tool_dataPointSelect.Serie_GetSeriesMark;
            line1.ClickTolerance      = 40;
            line1.RecalcOptions       = RecalcOptions.OnModify;
            line1.Title            = "Forest 1";
            line1.DefaultNullValue = 0;
            line1.VertAxis         = VerticalAxis.Both;
            line1.HorizAxis        = HorizontalAxis.Both;

            // Propiedades de la "line2"
            line2.LinePen = new ChartPen {
                Width = 6, Color = var.GetPaletteBasic[1],
            };
            line2.Pointer = new SeriesPointer(BaseChart.Chart, line2)
            {
                Color = var.GetPaletteBasic[1], InflateMargins = true, HorizSize = 11, VertSize = 11, Pen = new ChartPen {
                    EndCap = PenLineCap.Round, Color = Xamarin.Forms.Color.White, Width = 5
                }, Style = PointerStyles.Sphere
            };
            line2.SeriesColor         = var.GetPaletteBasic[1];
            line2.Chart.Zoom.Allow    = false;
            line2.Chart.Panning.Allow = ScrollModes.None;
            line2.LineHeight          = 25;
            line2.ClickableLine       = true;
            line2.ClickPointer       += tool_dataPointSelect.PointValue_Click;
            line2.GetSeriesMark      += tool_dataPointSelect.Serie_GetSeriesMark;
            line2.ClickTolerance      = 40;
            line2.RecalcOptions       = RecalcOptions.OnModify;
            line2.Title     = "Forest 2";
            line2.VertAxis  = VerticalAxis.Both;
            line2.HorizAxis = HorizontalAxis.Both;

            // Características de los ejes del "Chart" base
            BaseChart.Chart.Axes.Left.SetMinMax(BaseChart.Chart.Axes.Left.MinYValue, BaseChart.Chart.Axes.Left.MaxYValue);
            BaseChart.Chart.Axes.Bottom.SetMinMax(BaseChart.Chart.Axes.Bottom.MinXValue, BaseChart.Chart.Axes.Bottom.MaxXValue);
            BaseChart.Chart.Axes.Left.Labels.ValueFormat   = "0";
            BaseChart.Chart.Axes.Bottom.Labels.ValueFormat = "0";
            BaseChart.Chart.Axes.Bottom.Increment          = 20;
            BaseChart.Chart.Axes.Left.Increment            = 1;
            BaseChart.Chart.Axes.Left.Visible         = true;
            BaseChart.Chart.Axes.Left.Title           = null;
            BaseChart.Chart.Axes.Bottom.Title         = null;
            BaseChart.Chart.Axes.Left.AxisPen.Visible = false;
            BaseChart.Chart.Axes.Left.Ticks.Visible   = false;
            BaseChart.Chart.Axes.Left.Grid.Visible    = true;
            BaseChart.Chart.Legend.LegendStyle        = LegendStyles.Series;
            BaseChart.Chart.Axes.Bottom.Grid.Visible  = false;
            BaseChart.Chart.Panel.MarginLeft          = 5;


            // Themes Marks
            Themes.AplicarMarksTheme1(BaseChart);
            line1.Marks.Font.Size = 18;
            line2.Marks.Font.Size = 18;
            line1.Marks.TailParams.PointerWidth  = 0;
            line1.Marks.Arrow.Visible            = false;
            line2.Marks.TailParams.PointerWidth  = 0;
            line2.Marks.Arrow.Visible            = false;
            line1.Marks.ArrowLength              = 0;
            line2.Marks.ArrowLength              = 0;
            line1.Marks.TailParams.PointerHeight = 0;
            line2.Marks.TailParams.PointerHeight = 0;
        }