* UILineChart:增加实时数据的Demo
This commit is contained in:
parent
2456e75e06
commit
2ef88246cd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
25
SunnyUI.Demo/Charts/FLineChart.Designer.cs
generated
25
SunnyUI.Demo/Charts/FLineChart.Designer.cs
generated
@ -28,12 +28,15 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
this.uiSymbolButton1 = new Sunny.UI.UISymbolButton();
|
this.uiSymbolButton1 = new Sunny.UI.UISymbolButton();
|
||||||
this.uiImageButton3 = new Sunny.UI.UIImageButton();
|
this.uiImageButton3 = new Sunny.UI.UIImageButton();
|
||||||
this.uiImageButton2 = new Sunny.UI.UIImageButton();
|
this.uiImageButton2 = new Sunny.UI.UIImageButton();
|
||||||
this.uiImageButton1 = new Sunny.UI.UIImageButton();
|
this.uiImageButton1 = new Sunny.UI.UIImageButton();
|
||||||
this.uiLine1 = new Sunny.UI.UILine();
|
this.uiLine1 = new Sunny.UI.UILine();
|
||||||
this.LineChart = new Sunny.UI.UILineChart();
|
this.LineChart = new Sunny.UI.UILineChart();
|
||||||
|
this.uiSymbolButton2 = new Sunny.UI.UISymbolButton();
|
||||||
|
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||||
this.PagePanel.SuspendLayout();
|
this.PagePanel.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit();
|
||||||
@ -42,6 +45,7 @@
|
|||||||
//
|
//
|
||||||
// PagePanel
|
// PagePanel
|
||||||
//
|
//
|
||||||
|
this.PagePanel.Controls.Add(this.uiSymbolButton2);
|
||||||
this.PagePanel.Controls.Add(this.uiSymbolButton1);
|
this.PagePanel.Controls.Add(this.uiSymbolButton1);
|
||||||
this.PagePanel.Controls.Add(this.uiImageButton3);
|
this.PagePanel.Controls.Add(this.uiImageButton3);
|
||||||
this.PagePanel.Controls.Add(this.uiImageButton2);
|
this.PagePanel.Controls.Add(this.uiImageButton2);
|
||||||
@ -130,9 +134,26 @@
|
|||||||
this.LineChart.Text = "uiLineChart1";
|
this.LineChart.Text = "uiLineChart1";
|
||||||
this.LineChart.PointValue += new Sunny.UI.UILineChart.OnPointValue(this.LineChart_PointValue);
|
this.LineChart.PointValue += new Sunny.UI.UILineChart.OnPointValue(this.LineChart_PointValue);
|
||||||
//
|
//
|
||||||
|
// uiSymbolButton2
|
||||||
|
//
|
||||||
|
this.uiSymbolButton2.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.uiSymbolButton2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||||
|
this.uiSymbolButton2.Location = new System.Drawing.Point(454, 466);
|
||||||
|
this.uiSymbolButton2.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.uiSymbolButton2.Name = "uiSymbolButton2";
|
||||||
|
this.uiSymbolButton2.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
|
||||||
|
this.uiSymbolButton2.Size = new System.Drawing.Size(100, 27);
|
||||||
|
this.uiSymbolButton2.Symbol = 61463;
|
||||||
|
this.uiSymbolButton2.TabIndex = 36;
|
||||||
|
this.uiSymbolButton2.Text = "实时";
|
||||||
|
this.uiSymbolButton2.Click += new System.EventHandler(this.uiSymbolButton2_Click);
|
||||||
|
//
|
||||||
|
// timer1
|
||||||
|
//
|
||||||
|
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||||
|
//
|
||||||
// FLineChart
|
// FLineChart
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
|
||||||
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.Name = "FLineChart";
|
this.Name = "FLineChart";
|
||||||
@ -154,5 +175,7 @@
|
|||||||
private UIImageButton uiImageButton1;
|
private UIImageButton uiImageButton1;
|
||||||
private UILine uiLine1;
|
private UILine uiLine1;
|
||||||
private UILineChart LineChart;
|
private UILineChart LineChart;
|
||||||
|
private UISymbolButton uiSymbolButton2;
|
||||||
|
private System.Windows.Forms.Timer timer1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,10 @@ namespace Sunny.UI.Demo.Charts
|
|||||||
|
|
||||||
private void uiSymbolButton1_Click(object sender, EventArgs e)
|
private void uiSymbolButton1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
timer1.Stop();
|
||||||
|
|
||||||
|
DateTime dt = new DateTime(2020, 10, 4);
|
||||||
|
|
||||||
UILineOption option = new UILineOption();
|
UILineOption option = new UILineOption();
|
||||||
option.ToolTip.Visible = true;
|
option.ToolTip.Visible = true;
|
||||||
option.Title = new UITitle();
|
option.Title = new UITitle();
|
||||||
@ -22,7 +26,6 @@ namespace Sunny.UI.Demo.Charts
|
|||||||
option.XAxisType = UIAxisType.DateTime;
|
option.XAxisType = UIAxisType.DateTime;
|
||||||
|
|
||||||
var series = option.AddSeries(new UILineSeries("Line1"));
|
var series = option.AddSeries(new UILineSeries("Line1"));
|
||||||
DateTime dt = new DateTime(2020, 10, 4);
|
|
||||||
series.Add(dt.AddHours(0), 1.2);
|
series.Add(dt.AddHours(0), 1.2);
|
||||||
series.Add(dt.AddHours(1), 2.2);
|
series.Add(dt.AddHours(1), 2.2);
|
||||||
series.Add(dt.AddHours(2), 3.2);
|
series.Add(dt.AddHours(2), 3.2);
|
||||||
@ -55,8 +58,10 @@ namespace Sunny.UI.Demo.Charts
|
|||||||
|
|
||||||
option.XAxis.Name = "日期";
|
option.XAxis.Name = "日期";
|
||||||
option.YAxis.Name = "数值";
|
option.YAxis.Name = "数值";
|
||||||
option.XAxis.AxisLabel.DateTimeFormat = DateTimeEx.DateTimeFormat;
|
option.XAxis.AxisLabel.DateTimeFormat = "yyyy-MM-dd HH:mm";
|
||||||
|
option.XAxis.AxisLabel.AutoFormat = false;
|
||||||
option.YAxis.AxisLabel.DecimalCount = 1;
|
option.YAxis.AxisLabel.DecimalCount = 1;
|
||||||
|
option.YAxis.AxisLabel.AutoFormat = false;
|
||||||
|
|
||||||
option.XAxisScaleLines.Add(new UIScaleLine() { Color = Color.Red, Name = dt.AddHours(3).DateTimeString(), Value = new DateTimeInt64(dt.AddHours(3)) });
|
option.XAxisScaleLines.Add(new UIScaleLine() { Color = Color.Red, Name = dt.AddHours(3).DateTimeString(), Value = new DateTimeInt64(dt.AddHours(3)) });
|
||||||
option.XAxisScaleLines.Add(new UIScaleLine() { Color = Color.Red, Name = dt.AddHours(6).DateTimeString(), Value = new DateTimeInt64(dt.AddHours(6)) });
|
option.XAxisScaleLines.Add(new UIScaleLine() { Color = Color.Red, Name = dt.AddHours(6).DateTimeString(), Value = new DateTimeInt64(dt.AddHours(6)) });
|
||||||
@ -89,5 +94,43 @@ namespace Sunny.UI.Demo.Charts
|
|||||||
|
|
||||||
Console.WriteLine(sb.ToString());
|
Console.WriteLine(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void uiSymbolButton2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
UILineOption option = new UILineOption();
|
||||||
|
option.ToolTip.Visible = true;
|
||||||
|
option.Title = new UITitle();
|
||||||
|
option.Title.Text = "SunnyUI";
|
||||||
|
option.Title.SubText = "LineChart";
|
||||||
|
var series = option.AddSeries(new UILineSeries("Line1"));
|
||||||
|
series.Smooth = true;
|
||||||
|
|
||||||
|
option.XAxis.AxisLabel.DecimalCount = 1;
|
||||||
|
option.XAxis.AxisLabel.AutoFormat = false;
|
||||||
|
option.YAxis.AxisLabel.DecimalCount = 1;
|
||||||
|
option.YAxis.AxisLabel.AutoFormat = false;
|
||||||
|
LineChart.SetOption(option);
|
||||||
|
timer1.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
private void timer1_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LineChart.Option.AddData("Line1", index, random.NextDouble() * 10);
|
||||||
|
index++;
|
||||||
|
|
||||||
|
if (index > 50)
|
||||||
|
{
|
||||||
|
LineChart.Option.XAxis.Max = index + 20;
|
||||||
|
LineChart.Option.XAxis.MaxAuto = false;
|
||||||
|
LineChart.Option.XAxis.Min = index - 50;
|
||||||
|
LineChart.Option.XAxis.MinAuto = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LineChart.Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -10,10 +10,10 @@ namespace Sunny.UI.Demo
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
uiDataGridView1.AddColumn("Column1", "Column1").SetFixedMode(150);
|
uiDataGridView1.AddColumn("Column1", "Column1");
|
||||||
uiDataGridView1.AddColumn("Column2", "Column2").SetFixedMode(150);
|
uiDataGridView1.AddColumn("Column2", "Column2");
|
||||||
uiDataGridView1.AddColumn("Column3", "Column3").SetFixedMode(150);
|
uiDataGridView1.AddColumn("Column3", "Column3");
|
||||||
uiDataGridView1.AddColumn("Column4", "Column4").SetFixedMode(150);
|
uiDataGridView1.AddColumn("Column4", "Column4");
|
||||||
uiDataGridView1.ReadOnly = true;
|
uiDataGridView1.ReadOnly = true;
|
||||||
|
|
||||||
for (int i = 0; i < 3610; i++)
|
for (int i = 0; i < 3610; i++)
|
||||||
|
@ -57,7 +57,7 @@ namespace Sunny.UI.Demo
|
|||||||
Aside.CreateChildNode(parent, AddPage(new FPieChart()));
|
Aside.CreateChildNode(parent, AddPage(new FPieChart()));
|
||||||
Aside.CreateChildNode(parent, AddPage(new FDoughnutChart()));
|
Aside.CreateChildNode(parent, AddPage(new FDoughnutChart()));
|
||||||
Aside.CreateChildNode(parent, AddPage(new FBarChart()));
|
Aside.CreateChildNode(parent, AddPage(new FBarChart()));
|
||||||
Aside.CreateChildNode(parent, AddPage(new FBarChartEx()));
|
//Aside.CreateChildNode(parent, AddPage(new FBarChartEx()));
|
||||||
Aside.CreateChildNode(parent, AddPage(new FLineChart()));
|
Aside.CreateChildNode(parent, AddPage(new FLineChart()));
|
||||||
|
|
||||||
AddPage(new FColorful());
|
AddPage(new FColorful());
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -28,6 +29,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
|
[ToolboxItem(false)]
|
||||||
public sealed class UIBarChartEx : UIBarChart
|
public sealed class UIBarChartEx : UIBarChart
|
||||||
{
|
{
|
||||||
protected override void CalcData()
|
protected override void CalcData()
|
||||||
|
@ -68,6 +68,17 @@ namespace Sunny.UI
|
|||||||
NeedDraw = true;
|
NeedDraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Refresh()
|
||||||
|
{
|
||||||
|
base.Refresh();
|
||||||
|
if (Option != null)
|
||||||
|
{
|
||||||
|
SetOption(Option);
|
||||||
|
}
|
||||||
|
|
||||||
|
CalcData();
|
||||||
|
}
|
||||||
|
|
||||||
protected UIScale XScale;
|
protected UIScale XScale;
|
||||||
protected UIScale YScale;
|
protected UIScale YScale;
|
||||||
private double[] YLabels;
|
private double[] YLabels;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user