WinForms/ScrollableChart/ScrollableExample.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Media;
using LiveCharts;
using LiveCharts.Events;
using LiveCharts.Geared;
using LiveCharts.Wpf;
using Binding = System.Windows.Data.Binding;

namespace Geared.Winforms.ScrollableChart
{
    public partial class ScrollableExample : Form
    {
        private ScrollableViewModel _viewModel = new ScrollableViewModel();
        
        public ScrollableExample()
        {
            InitializeComponent();

            //Cartesian Chart
            cartesianChart1.Zoom = ZoomingOptions.X;
            cartesianChart1.DisableAnimations = true;
            cartesianChart1.Hoverable = false;

            cartesianChart1.Series.Add(new GLineSeries
            {
                Values = _viewModel.Values,
                StrokeThickness = 0,
                AreaLimit = 0,
                Fill = new SolidColorBrush(Color.FromRgb(33, 147, 240)),
                PointGeometry = null
            });
            var ax = new Axis
            {
                LabelFormatter = _viewModel.Formatter,
                Separator = new Separator {IsEnabled = false}
            };
            ax.RangeChanged += Axis_OnRangeChanged;
            cartesianChart1.AxisX.Add(ax);

            //Scroller Chart
            scrollerChart.DisableAnimations = true;
            scrollerChart.ScrollMode = ScrollMode.X;
            scrollerChart.ScrollBarFill = new SolidColorBrush(Color.FromArgb(37, 48, 48, 48));
            scrollerChart.DataTooltip = null;
            scrollerChart.Hoverable = false;
            scrollerChart.DataTooltip = null;
            scrollerChart.AxisX.Add(new Axis 
            {
                LabelFormatter = x => new DateTime((long) x).ToString("yyyy"),
                Separator = new Separator {IsEnabled = false},
                IsMerged = true,
                Foreground = new SolidColorBrush(Color.FromArgb(152, 0, 0, 0)),
                FontSize = 22,
                FontWeight = FontWeights.UltraBold
            });
            scrollerChart.AxisY.Add(new Axis {Separator = new Separator {IsEnabled = true}, ShowLabels = false});
            scrollerChart.Series.Add(new GLineSeries
后面还有 55 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。