コード例 #1
0
        private async Task LoadData()
        {
            var selectedCounty = _pickerCounties.SelectedIndex >= 0
                                     ? _viewModel.CountyList[_pickerCounties.Items[_pickerCounties.SelectedIndex]]
                                     : -1;
            var selectedChapter = _pickerChapters.SelectedIndex >= 0
                                      ? _pickerChapters.Items[_pickerChapters.SelectedIndex]
                                      : string.Empty;

            await _viewModel.GetChapterData(selectedCounty, selectedChapter);

            if (plotView == null)
            {
                return;
            }

            plotView.Model = new PlotModel();

            plotView.Model.TextColor = OxyColors.Aqua;

            var dtAxis = new DateTimeAxis();

            dtAxis.Position      = AxisPosition.Bottom;
            dtAxis.IntervalType  = DateTimeIntervalType.Months;
            dtAxis.StringFormat  = "yyyy-MM";
            dtAxis.IsPanEnabled  = false;
            dtAxis.IsZoomEnabled = false;

            var verticalAxis = new LinearAxis();

            verticalAxis.Position      = AxisPosition.Left;
            verticalAxis.IsPanEnabled  = false;
            verticalAxis.IsZoomEnabled = false;

            plotView.Model.Axes.Add(dtAxis);
            plotView.Model.Axes.Add(verticalAxis);

            var series = new LineSeries();

            series.ItemsSource = _viewModel.ChapterData;
            series.DataFieldX  = "TimeStamp";
            series.DataFieldY  = "Value";
            //series.Smooth = true;     // TODO: smooth or not?
            plotView.Model.Series.Clear();
            plotView.Model.Series.Add(series);

            plotView.Model.InvalidatePlot(true);
        }
コード例 #2
0
        private async Task LoadData()
        {
            Settings.County1 = _pickerCounties.SelectedIndex;
            Settings.County2 = _pickerCounties2.SelectedIndex;
            Settings.Chapter = _pickerChapters.SelectedIndex;

            var selectedCounty = _pickerCounties.SelectedIndex >= 0
                                     ? _viewModel.CountyList[_pickerCounties.Items[_pickerCounties.SelectedIndex]]
                                     : -1;
            var selectedCounty2 = _pickerCounties2.SelectedIndex >= 1
                                     ? _viewModel.CountyList[_pickerCounties.Items[_pickerCounties2.SelectedIndex - 1]]
                                     : -1;
            var selectedChapter = _pickerChapters.SelectedIndex >= 0
                                      ? _pickerChapters.Items[_pickerChapters.SelectedIndex]
                                      : string.Empty;

            await _viewModel.GetChapterData(selectedCounty, selectedCounty2, selectedChapter);

            if (plotView == null)
            {
                return;
            }

            plotView.Model       = new PlotModel();
            plotView.Model.Title = "Evolutie indicator";

            plotView.Model.TextColor = OxyColors.LightGray;

            var dtAxis = new DateTimeAxis();

            dtAxis.Position      = AxisPosition.Bottom;
            dtAxis.IntervalType  = DateTimeIntervalType.Months;
            dtAxis.StringFormat  = "yyyy-MM";
            dtAxis.IsPanEnabled  = false;
            dtAxis.IsZoomEnabled = false;

            var verticalAxis = new LinearAxis();

            verticalAxis.Position      = AxisPosition.Left;
            verticalAxis.IsPanEnabled  = false;
            verticalAxis.IsZoomEnabled = false;

            plotView.Model.Axes.Add(dtAxis);
            plotView.Model.Axes.Add(verticalAxis);

            plotView.Model.Series.Clear();

            var series = new LineSeries();

            series.ItemsSource = _viewModel.ChapterData;
            series.DataFieldX  = "TimeStamp";
            series.DataFieldY  = "Value";
            series.Title       = _pickerCounties.Items[_pickerCounties.SelectedIndex];
            plotView.Model.Series.Add(series);

            if (_viewModel.Value2ColumnVisibility)
            {
                var series2 = new LineSeries();
                series2.ItemsSource = _viewModel.ChapterData;
                series2.DataFieldX  = "TimeStamp";
                series2.DataFieldY  = "Value2";
                series2.Title       = _pickerCounties2.Items[_pickerCounties2.SelectedIndex];
                plotView.Model.Series.Add(series2);
            }

            plotView.Model.IsLegendVisible = plotView.Model.Series.Count > 1;

            if (plotView.Model.IsLegendVisible)
            {
                if (_isPortrait)
                {
                    plotView.Model.LegendPlacement   = LegendPlacement.Outside;
                    plotView.Model.LegendPosition    = LegendPosition.RightTop;
                    plotView.Model.LegendOrientation = LegendOrientation.Vertical;
                }
                else
                {
                    plotView.Model.LegendPlacement   = LegendPlacement.Outside;
                    plotView.Model.LegendPosition    = LegendPosition.TopRight;
                    plotView.Model.LegendOrientation = LegendOrientation.Horizontal;
                }
            }

            plotView.Model.InvalidatePlot(true);
        }