Ejemplo n.º 1
0
        private void ZoomChart(bool skipTransition)
        {
            chartView.Visibility = Visibility.Visible;

            long d         = chartView.GetSelectedDate();
            var  childData = data.childChartData;

            if (childData == null)
            {
                return;
            }

            if (!skipTransition || zoomedChartView.Visibility != Visibility.Visible)
            {
                zoomedChartView.UpdatePicker(childData, d);
            }
            zoomedChartView.SetDataPublic(childData);

            if (data.chartData.lines.Count > 1)
            {
                var lines        = chartView.GetLines();
                var zoomedLines  = zoomedChartView.GetLines();
                int enabledCount = 0;
                for (int i = 0; i < data.chartData.lines.Count; i++)
                {
                    bool found = false;
                    for (int j = 0; j < childData.lines.Count; j++)
                    {
                        var line = childData.lines[j];
                        if (line.id.Equals(data.chartData.lines[i].id))
                        {
                            bool check = lines[j].enabled;
                            zoomedLines[j].enabled = check;
                            zoomedLines[j].alpha   = check ? 1f : 0f;
                            //checkBoxes.get(i).checkBox.enabled = true;
                            //checkBoxes.get(i).checkBox.animate().alpha(1).start();
                            if (check)
                            {
                                enabledCount++;
                            }

                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        //checkBoxes.get(i).checkBox.enabled = false;
                        //checkBoxes.get(i).checkBox.animate().alpha(0).start();
                    }
                }

                if (enabledCount == 0)
                {
                    for (int i = 0; i < data.chartData.lines.Count; i++)
                    {
                        //checkBoxes.get(i).checkBox.enabled = true;
                        //checkBoxes.get(i).checkBox.animate().alpha(1).start();
                    }
                    return;
                }
            }

            data.activeZoom = d;

            //chartView.legendSignatureView.setAlpha(0f);
            chartView.selectionA      = 0;
            chartView.legendShowing   = false;
            chartView.animateLegentTo = false;

            zoomedChartView.UpdateColors();

            if (!skipTransition)
            {
                zoomedChartView.ClearSelection();
                chartHeaderView.zoomTo(zoomedChartView, d, true);
            }

            zoomedChartView.SetHeader(chartHeaderView);
            chartView.SetHeader(null);

            if (skipTransition)
            {
                chartView.Visibility       = Visibility.Collapsed;
                zoomedChartView.Visibility = Visibility.Visible;

                chartView.transitionMode       = BaseChartView.TRANSITION_MODE_NONE;
                zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE;
                //chartView.enabled = false;
                //zoomedChartView.enabled = true;
                chartHeaderView.zoomTo(zoomedChartView, d, false);
            }
            else
            {
                ValueAnimator animator = CreateTransitionAnimator(d, true);
                animator.AddListener(new AnimatorUpdateListener(null, animation =>
                {
                    _ = chartView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        chartView.Visibility = Visibility.Collapsed;
                    });

                    //chartView.enabled = false;
                    //zoomedChartView.enabled = true;
                    chartView.transitionMode       = BaseChartView.TRANSITION_MODE_NONE;
                    zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE;
                    //((Activity)getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                }));
                animator.Start();
            }
        }
Ejemplo n.º 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();
                }
            };
        }