Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            var entries = new Entry[]
            {
                new Entry(0, 0),
                new Entry(10, 13),
                new Entry(15, 10),
                new Entry(20, 4),
                new Entry(25, 8)
            };
            var dataSets = new LineDataSet[]
            {
                new LineDataSet(entries, "Sample")
                {
                    Mode           = LineDataSet.LineMode.CubicBezier,
                    ValueTextColor = SKColors.Black,
                    DrawFilled     = true,
                    Fill           = new GradientFill(SKColor.Parse("#266489"), SKColor.Parse("#68B9C0")),
                }.EnableDashedHighlightLine(10f, 10f, 0)
            };
            LineData data = new LineData(dataSets);

            data.NotifyDataChanged();
            var content = new LineChart()
            {
                Marker               = new XF.ChartLibrary.Components.MarkerText(),
                MaxVisibleCount      = 3,
                Data                 = data,
                VisibleXRangeMaximum = 15,
                VisibleXRangeMinimum = 5,
                XAxis                =
                {
                    SpaceMax           =    1,
                    GranularityEnabled = true,
                },
                AxisLeft =
                {
                    AxisMaximum = 30,
                    LimitLines  =
                    {
                        new XF.ChartLibrary.Components.LimitLine(10, "Max")
                        .EnableDashedLine(10f,                       10f, 0),
                        new XF.ChartLibrary.Components.LimitLine(0,  "Min")
                        .EnableDashedLine(10f,                       10f, 0),
                    }
                },
                AxisRight =
                {
                    IsEnabled = false
                },
                Legend =
                {
                    Form = XF.ChartLibrary.Components.Form.Line
                }
            };

            content.SetVisibleYRange(15, 5, XF.ChartLibrary.Components.YAxisDependency.Left);
            content.NotifyDataSetChanged();
            Root.Content = content;
        }
        public LineChartSample()
        {
            InitializeComponent();
            var dataSets = new LineDataSet[]
            {
                new LineDataSet(new Entry[]
                {
                    new Entry(0, 0),
                    new Entry(10, 10),
                    new Entry(20, 20),
                    new Entry(30, 25),
                    new Entry(40, 15),
                    new Entry(50, 40),
                    new Entry(60, 12),
                }, "Sample1")
                {
                    ValueFormatter = null,
                    Mode           = LineDataSet.LineMode.CubicBezier,
                    ValueTextColor = SKColors.Black,
                    DrawFilled     = true,
                    Color          = Color1,
                    FillColor      = Color1,
                }.EnableDashedHighlightLine(10f, 10f, 0),
                new LineDataSet(new Entry[]
                {
                    new Entry(0, 0),
                    new Entry(5, 10),
                    new Entry(15, 20),
                    new Entry(25, 22),
                    new Entry(40, 15),
                    new Entry(50, 30),
                    new Entry(60, 12),
                }, "Sample2")
                {
                    ValueFormatter = null,
                    Mode           = LineDataSet.LineMode.CubicBezier,
                    ValueTextColor = SKColors.Black,
                    DrawFilled     = true,
                    Color          = Color2,
                    FillColor      = Color2,
                }.EnableDashedHighlightLine(10f, 10f, 0)
            };
            LineData data = new LineData(dataSets);

            data.NotifyDataChanged();
            var xAxis = Chart.XAxis;

            xAxis.AxisRange = 100;
            xAxis.SpaceMax  = 1;
            var axisLeft = Chart.AxisLeft;

            axisLeft.AxisMaximum = 50;
            axisLeft.DrawLimitLinesBehindData = true;
            axisLeft.LimitLines.Add(new LimitLine(10, "Max")
                                    .EnableDashedLine(10f, 10f, 0));
            axisLeft.LimitLines.Add(new LimitLine(0, "Min")
                                    .EnableDashedLine(10f, 10f, 0));

            Chart.AxisRight.IsEnabled = false;
            Chart.Legend.Form         = Form.Circle;
            Chart.Data   = data;
            Chart.Marker = new MarkerViewXY();
            Chart.XAxis.ResetAxisMaximum();
            Chart.SetVisibleYRange(50, 10, YAxisDependency.Left);
            Chart.NotifyDataSetChanged();
        }