Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CartesianChart"/> class.
        /// </summary>
        /// <param name="tooltip">The default tool tip control.</param>
        /// <param name="legend">The default legend control.</param>
        public CartesianChart(IChartTooltip <SkiaSharpDrawingContext>?tooltip = null, IChartLegend <SkiaSharpDrawingContext>?legend = null)
            : base(tooltip, legend)
        {
            seriesObserver = new CollectionDeepObserver <ISeries>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            xObserver      = new CollectionDeepObserver <IAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            yObserver      = new CollectionDeepObserver <IAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);

            XAxes = new List <IAxis>()
            {
                new Axis()
            };
            YAxes = new List <IAxis>()
            {
                new Axis()
            };
            Series = new ObservableCollection <ISeries>();

            var c = Controls[0].Controls[0];

            c.MouseWheel += OnMouseWheel;
            c.MouseDown  += OnMouseDown;
            c.MouseMove  += OnMoseMove;
            c.MouseUp    += OnMouseUp;

            panningThrottler = new ActionThrottler(DoPan, TimeSpan.FromMilliseconds(30));
        }
Пример #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="PieChart"/> class.
    /// </summary>
    /// <param name="tooltip">The default tool tip control.</param>
    /// <param name="legend">The default legend.</param>
    public PieChart(IChartTooltip <SkiaSharpDrawingContext>?tooltip = null, IChartLegend <SkiaSharpDrawingContext>?legend = null)
        : base(tooltip, legend)
    {
        _seriesObserver = new CollectionDeepObserver <ISeries>(
            (object?sender, NotifyCollectionChangedEventArgs e) =>
        {
            if (sender is IStopNPC stop && !stop.IsNotifyingChanges)
            {
                return;
            }
            OnPropertyChanged();
        },
            (object?sender, PropertyChangedEventArgs e) =>
        {
            if (sender is IStopNPC stop && !stop.IsNotifyingChanges)
            {
                return;
            }
            OnPropertyChanged();
        },
            true);

        var c = Controls[0].Controls[0];

        c.MouseDown += OnMouseDown;
    }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CartesianChart"/> class.
        /// </summary>
        /// <param name="tooltip">The default tool tip control.</param>
        /// <param name="legend">The default legend control.</param>
        public CartesianChart(IChartTooltip <SkiaSharpDrawingContext>?tooltip = null, IChartLegend <SkiaSharpDrawingContext>?legend = null)
            : base(tooltip, legend)
        {
            _seriesObserver     = new CollectionDeepObserver <ISeries>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            _xObserver          = new CollectionDeepObserver <ICartesianAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            _yObserver          = new CollectionDeepObserver <ICartesianAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            _sectionsObserverer = new CollectionDeepObserver <Section <SkiaSharpDrawingContext> >(
                OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);

            XAxes = new List <ICartesianAxis>()
            {
                LiveCharts.CurrentSettings.AxisProvider()
            };
            YAxes = new List <ICartesianAxis>()
            {
                LiveCharts.CurrentSettings.AxisProvider()
            };
            Series = new ObservableCollection <ISeries>();

            var c = Controls[0].Controls[0];

            c.MouseWheel += OnMouseWheel;
            c.MouseDown  += OnMouseDown;
            c.MouseUp    += OnMouseUp;
        }
Пример #4
0
        public ChartItem()
        {
            SeriesCollection  = new SeriesCollection();
            DateTimeFormatter = ticks =>
                                (ticks >= DateTime.MinValue.Ticks && ticks <= DateTime.MaxValue.Ticks) ?
                                new DateTime((long)ticks).ToString("mm:ss") : string.Empty;
            AxisStep    = TimeSpan.FromSeconds(5).Ticks;
            MaxX        = MinX = MaxY = double.NaN;
            MinY        = 0;
            DataTooltip = null;

            SetAxisLimits(DateTime.Now);
        }
Пример #5
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (!(Template.FindName("canvas", this) is NaturalGeometriesCanvas canvas))
            {
                throw new Exception(
                          $"{nameof(SKElement)} not found. This was probably caused because the control {nameof(CartesianChart)} template was overridden, " +
                          $"If you override the template please add an {nameof(NaturalGeometriesCanvas)} to the template and name it 'canvas'");
            }

            this.canvas = canvas;
            core        = new ChartCore <SkiaDrawingContext>(this, canvas.CanvasCore);
            legend      = Template.FindName("legend", this) as IChartLegend <SkiaDrawingContext>;
            tooltip     = Template.FindName("tooltip", this) as IChartTooltip <SkiaDrawingContext>;
            core.Update();
        }
Пример #6
0
        private void UpdateThrottlerUnlocked()
        {
            // before measure every element in the chart
            // we copy the properties that might change while we are updating the chart
            // this call should be thread safe
            // ToDo: ensure it is thread safe...

            viewDrawMargin = chartView.DrawMargin;
            controlSize    = chartView.ControlSize;
            yAxes          = chartView.YAxes.Select(x => x.Copy()).ToArray();
            xAxes          = chartView.XAxes.Select(x => x.Copy()).ToArray();

            measureWorker = new object();
            series        = chartView.Series.Select(series =>
            {
                // a good implementation of ISeries<T>
                // must use the measureWorker to identify
                // if the points are already fetched.

                // this way no matter if the Series.Values collection changes
                // the fetch method will always return the same collection for the
                // current measureWorker instance

                series.Fetch(this);
                return(series);
            }).ToArray();

            legendPosition    = chartView.LegendPosition;
            legendOrientation = chartView.LegendOrientation;
            legend            = chartView.Legend; // ... this is a reference type.. this has no sense

            tooltipPosition        = chartView.TooltipPosition;
            tooltipFindingStrategy = chartView.TooltipFindingStrategy;
            tooltip = chartView.Tooltip; //... no sense again...

            animationsSpeed = chartView.AnimationsSpeed;
            easingFunction  = chartView.EasingFunction;

            Measure();
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PieChart"/> class.
 /// </summary>
 /// <param name="tooltip">The default tool tip control.</param>
 /// <param name="legend">The default legend.</param>
 public PieChart(IChartTooltip <SkiaSharpDrawingContext>?tooltip = null, IChartLegend <SkiaSharpDrawingContext>?legend = null)
     : base(tooltip, legend)
 {
     _seriesObserver = new CollectionDeepObserver <ISeries>(
         (object?sender, NotifyCollectionChangedEventArgs e) =>
     {
         if (core == null)
         {
             return;
         }
         core.Update();
     },
         (object?sender, PropertyChangedEventArgs e) =>
     {
         if (core == null)
         {
             return;
         }
         core.Update();
     },
         true);
 }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PolarChart"/> class.
        /// </summary>
        /// <param name="tooltip">The default tool tip control.</param>
        /// <param name="legend">The default legend control.</param>
        public PolarChart(IChartTooltip <SkiaSharpDrawingContext>?tooltip = null, IChartLegend <SkiaSharpDrawingContext>?legend = null)
            : base(tooltip, legend)
        {
            _seriesObserver = new CollectionDeepObserver <ISeries>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            _angleObserver  = new CollectionDeepObserver <IPolarAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);
            _radiusObserver = new CollectionDeepObserver <IPolarAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true);

            AngleAxes = new List <IPolarAxis>()
            {
                LiveCharts.CurrentSettings.PolarAxisProvider()
            };
            RadiusAxes = new List <IPolarAxis>()
            {
                LiveCharts.CurrentSettings.PolarAxisProvider()
            };
            Series = new ObservableCollection <ISeries>();

            var c = Controls[0].Controls[0];

            c.MouseWheel += OnMouseWheel;
            c.MouseDown  += OnMouseDown;
            c.MouseUp    += OnMouseUp;
        }