* UILineChart: 增加可只显示点的模式

This commit is contained in:
Sunny 2021-08-23 15:17:04 +08:00
parent fbcd33180d
commit f8d48b8c87
10 changed files with 41 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -36,6 +36,7 @@
this.LineChart = new Sunny.UI.UILineChart(); this.LineChart = new Sunny.UI.UILineChart();
this.uiSymbolButton2 = new Sunny.UI.UISymbolButton(); this.uiSymbolButton2 = new Sunny.UI.UISymbolButton();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.uiCheckBox1 = new Sunny.UI.UICheckBox();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton1)).BeginInit();
@ -128,11 +129,25 @@
// //
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
// //
// uiCheckBox1
//
this.uiCheckBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiCheckBox1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiCheckBox1.Location = new System.Drawing.Point(571, 505);
this.uiCheckBox1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiCheckBox1.Name = "uiCheckBox1";
this.uiCheckBox1.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
this.uiCheckBox1.Size = new System.Drawing.Size(100, 29);
this.uiCheckBox1.TabIndex = 37;
this.uiCheckBox1.Text = "显示点";
this.uiCheckBox1.CheckedChanged += new System.EventHandler(this.uiCheckBox1_CheckedChanged);
//
// FLineChart // FLineChart
// //
this.AllowShowTitle = true; this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 574); this.ClientSize = new System.Drawing.Size(800, 574);
this.Controls.Add(this.uiCheckBox1);
this.Controls.Add(this.uiSymbolButton2); this.Controls.Add(this.uiSymbolButton2);
this.Controls.Add(this.uiSymbolButton1); this.Controls.Add(this.uiSymbolButton1);
this.Controls.Add(this.uiImageButton3); this.Controls.Add(this.uiImageButton3);
@ -160,5 +175,6 @@
private UILineChart LineChart; private UILineChart LineChart;
private UISymbolButton uiSymbolButton2; private UISymbolButton uiSymbolButton2;
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
private UICheckBox uiCheckBox1;
} }
} }

View File

@ -132,5 +132,17 @@ namespace Sunny.UI.Demo.Charts
LineChart.Refresh(); LineChart.Refresh();
} }
private void uiCheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (LineChart.Option == null) return;
foreach (var series in LineChart.Option.Series.Values)
{
series.ShowLine = !uiCheckBox1.Checked;
series.Symbol = uiCheckBox1.Checked ? UILinePointSymbol.Circle : UILinePointSymbol.None;
}
LineChart.Refresh();
}
} }
} }

View File

@ -21,6 +21,7 @@
* 2021-04-15: V3.0.3 ZoomBack() * 2021-04-15: V3.0.3 ZoomBack()
* 2021-06-18: V3.0.4 * 2021-06-18: V3.0.4
* 2021-07-22: V3.0.5 Demo * 2021-07-22: V3.0.5 Demo
* 2021-08-23: V3.0.6
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -306,14 +307,17 @@ namespace Sunny.UI
return; return;
} }
using (Pen pen = new Pen(color, series.Width)) if (series.ShowLine || series.Symbol == UILinePointSymbol.None)
{ {
g.SetHighQuality(); using (Pen pen = new Pen(color, series.Width))
if (series.Smooth) {
g.DrawCurve(pen, series.Points.ToArray()); g.SetHighQuality();
else if (series.Smooth)
g.DrawLines(pen, series.Points.ToArray()); g.DrawCurve(pen, series.Points.ToArray());
g.SetDefaultQuality(); else
g.DrawLines(pen, series.Points.ToArray());
g.SetDefaultQuality();
}
} }
} }

View File

@ -261,6 +261,8 @@ namespace Sunny.UI
public bool Smooth { get; set; } public bool Smooth { get; set; }
public bool ShowLine { get; set; } = true;
public UILineSeries(string name) public UILineSeries(string name)
{ {
Name = name; Name = name;