Диаграмма вертикальной настройки сетки для временных рядов - PullRequest
0 голосов
/ 14 января 2020

У меня есть приложение WinForms, и я хотел бы иметь вертикальные линии сетки на моем графике, только если начался новый день. Есть ли способ сделать это?

Windows Сгенерированный конструктором форм метод InitializeComponent:

System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
        System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
        System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
        this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
        ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
        this.SuspendLayout();
        // 
        // chart1
        // 
        this.chart1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right)));
        chartArea1.AxisX.MajorGrid.IntervalOffsetType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;
        chartArea1.AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;
        chartArea1.AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
        chartArea1.AxisX.ScrollBar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
        chartArea1.AxisX.ScrollBar.ButtonColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
        chartArea1.AxisX2.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;
        chartArea1.Name = "ChartArea1";
        this.chart1.ChartAreas.Add(chartArea1);
        this.chart1.Cursor = System.Windows.Forms.Cursors.Default;
        legend1.Enabled = false;
        legend1.Name = "Legend1";
        this.chart1.Legends.Add(legend1);
        this.chart1.Location = new System.Drawing.Point(1, 1);
        this.chart1.Name = "chart1";
        series1.ChartArea = "ChartArea1";
        series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Candlestick;
        series1.Legend = "Legend1";
        series1.Name = "HLOCSeries";
        series1.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
        series1.YValuesPerPoint = 4;
        this.chart1.Series.Add(series1);
        this.chart1.Size = new System.Drawing.Size(478, 224);
        this.chart1.TabIndex = 1;
        this.chart1.Text = "chart1";
        // 
        // TestForm
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(480, 224);
        this.Controls.Add(this.chart1);
        this.Name = "TestForm";
        this.Text = "SummaryWindow";
        ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
        this.ResumeLayout(false);

Например:

enter image description here

Файл Form1.Designer.cs: https://pastebin.com/6ssiDeBt

Файл Form1.cs: https://pastebin.com/KgtVJaNg

1 Ответ

0 голосов
/ 20 января 2020

Настройки ниже решили мою проблему:

        chartArea1.AxisX.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;
        chartArea1.AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.FixedCount;
        chartArea1.AxisX.Interval = 1;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...