Exemplo n.º 1
0
        private void ZoomOut(bool animated)
        {
            if (data.chartData.x == null)
            {
                return;
            }
            chartHeaderView.zoomOut(chartView, animated);
            //chartView.legendSignatureView.chevron.setAlpha(1f);
            zoomedChartView.SetHeader(null);

            long d = chartView.GetSelectedDate();

            data.activeZoom = 0;

            //chartView.Visibility = Visibility.Visible;
            zoomedChartView.ClearSelection();

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

            if (!animated)
            {
                zoomedChartView.Visibility = Visibility.Collapsed;
                //chartView.enabled = true;
                //zoomedChartView.enabled = false;
                chartView.Invalidate();
                //((Activity)getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

                //for (CheckBoxHolder checkbox : checkBoxes)
                //{
                //    checkbox.checkBox.setAlpha(1);
                //    checkbox.checkBox.enabled = true;
                //}
            }
            else
            {
                ValueAnimator animator = CreateTransitionAnimator(d, false);
                animator.AddListener(new AnimatorUpdateListener(animator =>
                {
                    _ = zoomedChartView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        zoomedChartView.Visibility = Visibility.Collapsed;
                    });

                    chartView.transitionMode       = BaseChartView.TRANSITION_MODE_NONE;
                    zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE;

                    //chartView.enabled = true;
                    //zoomedChartView.enabled = false;

                    if (chartView is not StackLinearChartView)
                    {
                        chartView.legendShowing = true;
                        chartView.MoveLegend();
                        chartView.AnimateLegend(true);
                        chartView.Invalidate();
                    }
                    else
                    {
                        chartView.legendShowing = false;
                        chartView.ClearSelection();
                    }
                    //((Activity)getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                }));
                //for (CheckBoxHolder checkbox : checkBoxes)
                //{
                //    checkbox.checkBox.animate().alpha(1f).start();
                //    checkbox.checkBox.enabled = true;
                //}
                animator.Start();
            }
        }
Exemplo n.º 2
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();
            }
        }