예제 #1
0
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (sender is CheckBox check && check.DataContext is LineViewData line)
            {
                var lines = chartView.GetLines();
                if (line.enabled && lines.Except(new[] { line }).Any(x => x.enabled))
                {
                    line.enabled    = false;
                    check.IsChecked = false;

                    chartView.OnCheckChanged();
                }
                else if (!line.enabled)
                {
                    line.enabled    = true;
                    check.IsChecked = true;

                    chartView.OnCheckChanged();
                }
                else
                {
                    VisualUtilities.ShakeView(check);
                    return;
                }

                if (data.activeZoom > 0 && zoomedChartView != null)
                {
                    var zoomedLines = zoomedChartView.GetLines();

                    var position = lines.IndexOf(line);
                    if (position < zoomedLines.Count)
                    {
                        zoomedLines[position].enabled = line.enabled;
                        zoomedChartView.OnCheckChanged();
                    }
                }

                //var border =

                //test.onCheckChanged();
            }
        }
예제 #2
0
        public void UpdateData(ChartViewData data)
        {
            //if (args.ItemIndex != _loadIndex)
            //{
            //    root.Header = data.title;
            //    return;
            //}

            BaseChartView chartView       = null;
            BaseChartView zoomedChartView = null;

            switch (data.graphType)
            {
            case 1:
                chartView = new DoubleLinearChartView();
                //zoomedChartView = new DoubleLinearChartView();
                //zoomedChartView.legendSignatureView.useHour = true;
                break;

            case 2:
                chartView = new StackBarChartView();
                //zoomedChartView = new StackBarChartView();
                //zoomedChartView.legendSignatureView.useHour = true;
                break;

            case 3:
                chartView = new BarChartView();
                //zoomedChartView = new LinearChartView();
                //zoomedChartView.legendSignatureView.useHour = true;
                break;

            case 4:
                chartView = new StackLinearChartView();
                chartView.legendSignatureView.showPercentage = true;
                //zoomedChartView = new PieChartView();
                break;

            case 5:
                chartView = new StepChartView();
                chartView.legendSignatureView.isTopHourChart = true;
                //zoomedChartView = new LinearChartView();
                //zoomedChartView.legendSignatureView.useHour = true;
                break;

            case 6:
                chartView = new DoubleStepChartView();
                //zoomedChartView = new DoubleLinearChartView();
                //zoomedChartView.legendSignatureView.useHour = true;
                break;

            default:
                chartView = new LinearChartView();
                //zoomedChartView = new LinearChartView();
                //zoomedChartView.legendSignatureView.useHour = true;
                break;
            }

            LayoutRoot.Children.Clear();
            LayoutRoot.Children.Add(chartView);

            this.data            = data;
            this.chartView       = chartView;
            this.zoomedChartView = zoomedChartView;

            if (zoomedChartView != null)
            {
                chartView.Tapped += (s, args) =>
                {
                    OnZoomed();
                };

                chartHeaderView.Click += (s, args) =>
                {
                    ZoomOut(true);
                };

                LayoutRoot.Children.Add(zoomedChartView);
                zoomedChartView.Visibility = Visibility.Collapsed;
            }

            CheckPanel.Children.Clear();

            chartView.SetHeader(chartView.legendSignatureView.isTopHourChart ? null : chartHeaderView);
            chartView.Loaded += (s, args) =>
            {
                chartView.SetDataPublic(data.chartData);

                var lines = chartView.GetLines();
                if (lines.Count > 1)
                {
                    foreach (var line in lines)
                    {
                        var check = new FauxCheckBox();
                        check.Style       = BootStrapper.Current.Resources["LineCheckBoxStyle"] as Style;
                        check.Content     = line.line.name;
                        check.IsChecked   = line.enabled;
                        check.Background  = new SolidColorBrush(line.lineColor);
                        check.Margin      = new Thickness(12, 0, 0, 12);
                        check.DataContext = line;
                        check.Click      += CheckBox_Checked;

                        CheckPanel.Children.Add(check);
                    }

                    CheckPanel.Visibility = Visibility.Visible;
                }
                else
                {
                    CheckPanel.Visibility = Visibility.Collapsed;
                }

                if (zoomedChartView == null)
                {
                    return;
                }

                if (data.activeZoom > 0)
                {
                    chartView.SelectDate(data.activeZoom);
                    ZoomChart(true);
                }
                else
                {
                    ZoomOut(false);
                    //chartView.invalidate();
                }
            };
        }