预览
代码
手机端效果
web端效果
demoLineChart.cs
demoLineChart.Designer.cs
web:demoLineChart.cs
web:demoLineChart.Designer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smobiler.Core;
using Smobiler.Core.Controls;
using System.Data;
namespace Smobiler.Tutorials.Components
{
partial class demoLineChart : Smobiler.Core.Controls.MobileForm
{
public demoLineChart()
: base()
{
//This call is required by the SmobilerForm.
InitializeComponent();
}
DataTable dt = null;
private void title1_ImagePress(object sender, EventArgs e)
{
this.Close();
}
private void button1_Press(object sender, EventArgs e)
{
this.popList1.ShowDialog();
}
private void demoLineChart_Load(object sender, EventArgs e)
{
PopListGroup g1 = new PopListGroup();
g1.AddListItem("DataBind");
g1.AddListItem("XAxis");
g1.AddListItem("AddSet");
g1.AddListItem("RemoveSet");
g1.AddListItem("ClearSet");
g1.AddListItem("SetData");
popList1.Groups.Add(g1);
}
private void popList1_Selected(object sender, EventArgs e)
{
switch (popList1.Selections[0].Text)
{
case "DataBind":
DataBind();
break;
case "XAxis":
this.lineChart1.XAxis.XOffset = 1;
this.lineChart1.XAxis.YOffset = 1;
this.lineChart1.XAxis.TextSize = 10;
this.lineChart1.XAxis.TextColor = System.Drawing.Color.Red;
this.lineChart1.XAxis.DrawAxisLine = false;
this.lineChart1.XAxis.DrawGridLines = false;
this.lineChart1.XAxis.DrawLabels = false;
this.lineChart1.XAxis.GridLineWidth = 5;
this.lineChart1.XAxis.AxisLineWidth = 5;
this.lineChart1.XAxis.GridColor = System.Drawing.Color.Blue;
this.lineChart1.XAxis.AxisLineColor = System.Drawing.Color.Gray;
this.lineChart1.XAxis.Position = XAxisPosition.TOP;
break;
case "AddSet":
this.lineChart1.Data.AddSeries(GetNewSerie(this.lineChart1.Data));
break;
case "RemoveSet":
if (this.lineChart1.Data.SeriesCount > 0)
{
this.lineChart1.Data.RemoveSeries(0);
}
break;
case "ClearSet":
this.lineChart1.Data.ClearValues();
break;
case "SetData":
List xLabels = new List();
xLabels.AddRange(new string[] { "2019-09-01", "2019-09-02", "2019-09-03", "2019-09-04", "2019-09-05", "2019-09-06", "2019-09-07", "2019-09-08", "2019-09-09", "2019-09-10", "2019-09-11", "2019-09-12", "2019-09-13", "2019-09-14", "2019-09-15", "2019-09-16", "2019-09-17", "2019-09-18", "2019-09-19", "2019-09-20", "2019-09-21", "2019-09-22", "2019-09-23", "2019-09-24", "2019-09-25", "2019-09-26", "2019-09-27", "2019-09-28", "2019-09-29", "2019-09-30", "2019-09-31"});
LineData data = new LineData(xLabels);
data.AddSeries(GetNewSerie(data));
this.lineChart1.Data = data;
break;
}
}
private void DataBind()
{
//设置数据
this.lineChart1.SeriesMember = "S";
this.lineChart1.XValueMember = "X";
this.lineChart1.YValueMember = "Y";
dt = DemoGlobal.GetChartDemoTable();
this.lineChart1.DataSource = dt;
this.lineChart1.DataBind();
//填充随机颜色
int count = this.lineChart1.Data.SeriesCount;
for (int i = 0; i < count; i += 1)
{
LineSeries series = this.lineChart1.Data.GetSeries(i);
series.DrawFilled = true;
series.DrawFilledColor = DemoGlobal.GetRandomColor();
}
}
private LineSeries GetNewSerie(LineData data)
{
Random countRandom = new Random();
ChartYAxisValueCollection yVals = new ChartYAxisValueCollection();
int count = data.XAxisCount;
for (int i = 0; i < count; i++)
{
yVals.Add(new ChartYAxisValue(countRandom.Next(0, count)));
}
LineSeries set1 = new LineSeries(yVals, "DataSet 1");
set1.Color = DemoGlobal.GetRandomColor();
set1.DrawFilled = true;
set1.DrawCubic = true;
set1.DrawFilledColor = DemoGlobal.GetRandomColor();
return set1;
}
private void lineChart1_ValueSelected(object sender, LineChartValueSelectedEventArgs e)
{
Toast(string.Format("X:{0}/Y:{1}", e.XValue, e.YValue.Val));
}
}
}
using System;
using Smobiler.Core;
namespace Smobiler.Tutorials.Components
{
partial class demoLineChart : Smobiler.Core.Controls.MobileForm
{
#region "SmobilerForm generated code "
//SmobilerForm overrides dispose to clean up the component list.
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
//NOTE: The following procedure is required by the SmobilerForm
//It can be modified using the SmobilerForm.
//Do not modify it using the code editor.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
this.title1 = new Smobiler.Core.Controls.Title();
this.panel10 = new Smobiler.Core.Controls.Panel();
this.panel1 = new Smobiler.Core.Controls.Panel();
this.labContent = new Smobiler.Core.Controls.Label();
this.labTitle = new Smobiler.Core.Controls.Label();
this.button1 = new Smobiler.Core.Controls.Button();
this.lineChart1 = new Smobiler.Core.Controls.LineChart();
this.popList1 = new Smobiler.Core.Controls.PopList();
//
// title1
//
this.title1.ImageType = Smobiler.Core.Controls.ImageEx.ImageStyle.FontIcon;
this.title1.Name = "title1";
this.title1.ResourceID = "angle-left";
this.title1.Size = new System.Drawing.Size(300, 30);
this.title1.Text = "LineChart";
this.title1.ImagePress += new System.EventHandler(this.title1_ImagePress);
//
// panel10
//
this.panel10.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.panel1,
this.lineChart1});
this.panel10.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel10.Location = new System.Drawing.Point(0, 30);
this.panel10.Name = "panel10";
this.panel10.Scrollable = true;
this.panel10.Size = new System.Drawing.Size(300, 970);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Border = new Smobiler.Core.Controls.Border(1F);
this.panel1.BorderColor = System.Drawing.Color.Silver;
this.panel1.BorderRadius = 5;
this.panel1.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.labContent,
this.labTitle,
this.button1});
this.panel1.Location = new System.Drawing.Point(5, 9);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(290, 123);
//
// labContent
//
this.labContent.BackColor = System.Drawing.Color.WhiteSmoke;
this.labContent.FontSize = 15F;
this.labContent.Location = new System.Drawing.Point(0, 26);
this.labContent.Name = "labContent";
this.labContent.Padding = new Smobiler.Core.Controls.Padding(5F);
this.labContent.Size = new System.Drawing.Size(290, 54);
this.labContent.Text = "可进行数据绑定,添加数据集,删除数据集,清除数据集,设置数据集的操作\r\n";
//
// labTitle
//
this.labTitle.BackColor = System.Drawing.Color.WhiteSmoke;
this.labTitle.Border = new Smobiler.Core.Controls.Border(0F, 0F, 0F, 1F);
this.labTitle.BorderColor = System.Drawing.Color.DarkSeaGreen;
this.labTitle.FontSize = 16F;
this.labTitle.Name = "labTitle";
this.labTitle.Padding = new Smobiler.Core.Controls.Padding(5F);
this.labTitle.Size = new System.Drawing.Size(290, 26);
this.labTitle.Text = "线状图表";
//
// button1
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(229)))), ((int)(((byte)(99)))));
this.button1.FontSize = 15F;
this.button1.ForeColor = System.Drawing.Color.DimGray;
this.button1.Location = new System.Drawing.Point(39, 87);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(212, 30);
this.button1.Text = "控件介绍";
this.button1.Press += new System.EventHandler(this.button1_Press);
//
// lineChart1
//
this.lineChart1.Location = new System.Drawing.Point(0, 144);
this.lineChart1.Name = "lineChart1";
this.lineChart1.Size = new System.Drawing.Size(300, 300);
this.lineChart1.XAxisValues = new string[0];
this.lineChart1.ValueSelected += new Smobiler.Core.Controls.LineChartValueSelectedEventHandler(this.lineChart1_ValueSelected);
//
// popList1
//
this.popList1.Name = "popList1";
this.popList1.Selected += new System.EventHandler(this.popList1_Selected);
//
// demoLineChart
//
this.Components.AddRange(new Smobiler.Core.Controls.MobileComponent[] {
this.popList1});
this.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.title1,
this.panel10});
this.Load += new System.EventHandler(this.demoLineChart_Load);
this.Name = "demoLineChart";
}
#endregion
private Core.Controls.Title title1;
private Core.Controls.Panel panel10;
private Core.Controls.Panel panel1;
private Core.Controls.Label labContent;
private Core.Controls.Label labTitle;
private Core.Controls.Button button1;
private Core.Controls.LineChart lineChart1;
private Core.Controls.PopList popList1;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smobiler.Core;
using Smobiler.Core.Controls;
namespace SmobilerTutorialsWeb.Components
{
partial class demoLine : Smobiler.Core.Controls.MobileForm
{
public demoLine() : base()
{
//This call is required by the SmobilerForm.
InitializeComponent();
}
private void title1_ImagePress(object sender, EventArgs e)
{
this.Close();
}
}
}
using System;
using Smobiler.Core;
namespace SmobilerTutorialsWeb.Components
{
partial class demoLine : Smobiler.Core.Controls.MobileForm
{
#region "SmobilerForm generated code "
//SmobilerForm overrides dispose to clean up the component list.
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
//NOTE: The following procedure is required by the SmobilerForm
//It can be modified using the SmobilerForm.
//Do not modify it using the code editor.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
this.title1 = new Smobiler.Core.Controls.Title();
this.panel2 = new Smobiler.Core.Controls.Panel();
this.panel1 = new Smobiler.Core.Controls.Panel();
this.labContent = new Smobiler.Core.Controls.Label();
this.line1 = new Smobiler.Core.Controls.Line();
this.line2 = new Smobiler.Core.Controls.Line();
this.line3 = new Smobiler.Core.Controls.Line();
this.line4 = new Smobiler.Core.Controls.Line();
this.line5 = new Smobiler.Core.Controls.Line();
this.line6 = new Smobiler.Core.Controls.Line();
this.line7 = new Smobiler.Core.Controls.Line();
this.line8 = new Smobiler.Core.Controls.Line();
this.labTitle = new Smobiler.Core.Controls.Label();
//
// title1
//
this.title1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(246)))), ((int)(((byte)(246)))), ((int)(((byte)(246)))));
this.title1.ImageType = Smobiler.Core.Controls.ImageEx.ImageStyle.FontIcon;
this.title1.Name = "title1";
this.title1.ResourceID = "angle-left";
this.title1.Size = new System.Drawing.Size(0, 30);
this.title1.Text = "Line";
this.title1.ImagePress += new System.EventHandler(this.title1_ImagePress);
//
// panel2
//
this.panel2.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.panel1,
this.labTitle});
this.panel2.Flex = 1;
this.panel2.Name = "panel2";
this.panel2.Scrollable = true;
this.panel2.Size = new System.Drawing.Size(0, 100);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Border = new Smobiler.Core.Controls.Border(1F);
this.panel1.BorderColor = System.Drawing.Color.Silver;
this.panel1.BorderRadius = 5;
this.panel1.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.labContent,
this.line1,
this.line2,
this.line3,
this.line4,
this.line5,
this.line6,
this.line7,
this.line8});
this.panel1.Location = new System.Drawing.Point(300, 57);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(600, 363);
//
// labContent
//
this.labContent.HorizontalAlignment = Smobiler.Core.Controls.HorizontalAlignment.Center;
this.labContent.Location = new System.Drawing.Point(0, 305);
this.labContent.Name = "labContent";
this.labContent.Padding = new Smobiler.Core.Controls.Padding(5F);
this.labContent.Size = new System.Drawing.Size(600, 57);
this.labContent.Text = "线条控件,基础控件,其中Orientation设置线条方向";
//
// line1
//
this.line1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(176)))), ((int)(((byte)(249)))));
this.line1.Location = new System.Drawing.Point(67, 61);
this.line1.Name = "line1";
this.line1.Size = new System.Drawing.Size(80, 7);
//
// line2
//
this.line2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(229)))), ((int)(((byte)(99)))));
this.line2.Location = new System.Drawing.Point(67, 98);
this.line2.Name = "line2";
this.line2.Size = new System.Drawing.Size(200, 6);
//
// line3
//
this.line3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(192)))), ((int)(((byte)(78)))));
this.line3.Location = new System.Drawing.Point(67, 134);
this.line3.Name = "line3";
this.line3.Size = new System.Drawing.Size(200, 4);
//
// line4
//
this.line4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(176)))), ((int)(((byte)(249)))));
this.line4.Location = new System.Drawing.Point(399, 61);
this.line4.Name = "line4";
this.line4.Orientation = Smobiler.Core.Controls.OrientationAlignment.Vertical;
this.line4.Size = new System.Drawing.Size(8, 80);
//
// line5
//
this.line5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(229)))), ((int)(((byte)(99)))));
this.line5.Location = new System.Drawing.Point(440, 61);
this.line5.Name = "line5";
this.line5.Orientation = Smobiler.Core.Controls.OrientationAlignment.Vertical;
this.line5.Size = new System.Drawing.Size(6, 200);
//
// line6
//
this.line6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(192)))), ((int)(((byte)(78)))));
this.line6.Location = new System.Drawing.Point(474, 61);
this.line6.Name = "line6";
this.line6.Orientation = Smobiler.Core.Controls.OrientationAlignment.Vertical;
this.line6.Size = new System.Drawing.Size(4, 200);
//
// line7
//
this.line7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(67)))), ((int)(((byte)(81)))));
this.line7.Location = new System.Drawing.Point(508, 61);
this.line7.Name = "line7";
this.line7.Orientation = Smobiler.Core.Controls.OrientationAlignment.Vertical;
this.line7.Size = new System.Drawing.Size(1, 200);
//
// line8
//
this.line8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(67)))), ((int)(((byte)(81)))));
this.line8.Location = new System.Drawing.Point(67, 168);
this.line8.Name = "line8";
this.line8.Size = new System.Drawing.Size(200, 1);
//
// labTitle
//
this.labTitle.BackColor = System.Drawing.Color.White;
this.labTitle.Bold = true;
this.labTitle.Border = new Smobiler.Core.Controls.Border(0F, 0F, 0F, 1F);
this.labTitle.BorderColor = System.Drawing.Color.White;
this.labTitle.FontSize = 16F;
this.labTitle.Location = new System.Drawing.Point(300, 30);
this.labTitle.Name = "labTitle";
this.labTitle.Size = new System.Drawing.Size(600, 26);
this.labTitle.Text = "不同样式的线条";
//
// demoLine
//
this.BackColor = System.Drawing.Color.White;
this.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.title1,
this.panel2});
this.Layout = Smobiler.Core.Controls.LayoutPosition.Relative;
this.Size = new System.Drawing.Size(1200, 800);
this.Name = "demoLine";
}
#endregion
private Smobiler.Core.Controls.Title title1;
private Smobiler.Core.Controls.Panel panel2;
private Smobiler.Core.Controls.Panel panel1;
private Smobiler.Core.Controls.Label labContent;
private Smobiler.Core.Controls.Line line1;
private Smobiler.Core.Controls.Line line2;
private Smobiler.Core.Controls.Line line3;
private Smobiler.Core.Controls.Line line4;
private Smobiler.Core.Controls.Line line5;
private Smobiler.Core.Controls.Line line6;
private Smobiler.Core.Controls.Label labTitle;
private Smobiler.Core.Controls.Line line7;
private Smobiler.Core.Controls.Line line8;
}
}