Commit b59938b4 HZH

饼状图

1 个父辈 fed1749f
...@@ -927,7 +927,7 @@ namespace HZH_Controls.Controls ...@@ -927,7 +927,7 @@ namespace HZH_Controls.Controls
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
BackColor = System.Drawing.Color.Transparent; BackColor = System.Drawing.Color.Transparent;
ForeColor = System.Drawing.Color.Black; ForeColor = System.Drawing.Color.Black;
base.Name = "HslBarChart"; base.Name = "UCBarChart";
base.Size = new System.Drawing.Size(440, 264); base.Size = new System.Drawing.Size(440, 264);
ResumeLayout(false); ResumeLayout(false);
} }
......
using System.Drawing;
namespace HZH_Controls.Controls
{
public class PieItem
{
public string Name
{
get;
set;
}
public int Value
{
get;
set;
}
/// <summary>
/// Gets or sets the color of the pie.如果为空则使用默认颜色
/// </summary>
/// <value>The color of the pie.</value>
public Color? PieColor
{
get;
set;
}
}
}
...@@ -46,18 +46,22 @@ ...@@ -46,18 +46,22 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\Charts\AuxiliaryLine.cs" /> <Compile Include="Controls\Charts\BarChart\AuxiliaryLine.cs" />
<Compile Include="Controls\Charts\Axis.cs" /> <Compile Include="Controls\Charts\Axis.cs" />
<Compile Include="Controls\Charts\AxisCollection.cs" /> <Compile Include="Controls\Charts\AxisCollection.cs" />
<Compile Include="Controls\Charts\AxisFormat.cs" /> <Compile Include="Controls\Charts\AxisFormat.cs" />
<Compile Include="Controls\Charts\AxisLabel.cs" /> <Compile Include="Controls\Charts\AxisLabel.cs" />
<Compile Include="Controls\Charts\AxisPosition.cs" /> <Compile Include="Controls\Charts\AxisPosition.cs" />
<Compile Include="Controls\Charts\AxisType.cs" /> <Compile Include="Controls\Charts\AxisType.cs" />
<Compile Include="Controls\Charts\BarChartItem.cs" /> <Compile Include="Controls\Charts\BarChart\BarChartItem.cs" />
<Compile Include="Controls\Charts\ChartPoint.cs" /> <Compile Include="Controls\Charts\ChartPoint.cs" />
<Compile Include="Controls\Charts\ChartPointCollection.cs" /> <Compile Include="Controls\Charts\ChartPointCollection.cs" />
<Compile Include="Controls\Charts\ChartPointEventArgs.cs" /> <Compile Include="Controls\Charts\ChartPointEventArgs.cs" />
<Compile Include="Controls\Charts\ChartPointEventHandler.cs" /> <Compile Include="Controls\Charts\ChartPointEventHandler.cs" />
<Compile Include="Controls\Charts\PieChart\UCPieChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Charts\PieChart\PieItem.cs" />
<Compile Include="Controls\ScrollBar\ScrollbarComponent.cs"> <Compile Include="Controls\ScrollBar\ScrollbarComponent.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
...@@ -66,7 +70,7 @@ ...@@ -66,7 +70,7 @@
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Helpers\GraphDirection.cs" /> <Compile Include="Helpers\GraphDirection.cs" />
<Compile Include="Controls\Charts\UCBarChart.cs"> <Compile Include="Controls\Charts\BarChart\UCBarChart.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\Charts\UCChart.cs"> <Compile Include="Controls\Charts\UCChart.cs">
......
...@@ -816,9 +816,22 @@ namespace HZH_Controls ...@@ -816,9 +816,22 @@ namespace HZH_Controls
static ControlHelper() static ControlHelper()
{ {
List<Color> list = new List<Color>(); List<Color> list = new List<Color>();
list.Add(Color.FromArgb(55, 162, 218));
list.Add(Color.FromArgb(50, 197, 233));
list.Add(Color.FromArgb(103, 224, 227));
list.Add(Color.FromArgb(159, 230, 184));
list.Add(Color.FromArgb(255, 219, 92));
list.Add(Color.FromArgb(255, 159, 127));
list.Add(Color.FromArgb(251, 114, 147));
list.Add(Color.FromArgb(224, 98, 174));
list.Add(Color.FromArgb(230, 144, 209));
list.Add(Color.FromArgb(231, 188, 243));
list.Add(Color.FromArgb(157, 150, 245));
list.Add(Color.FromArgb(131, 120, 234));
list.Add(Color.FromArgb(150, 191, 255));
list.Add(Color.FromArgb(243, 67, 54)); list.Add(Color.FromArgb(243, 67, 54));
list.Add(Color.FromArgb(156, 39, 176)); list.Add(Color.FromArgb(156, 39, 176));
list.Add(Color.FromArgb(233, 30, 99));
list.Add(Color.FromArgb(103, 58, 183)); list.Add(Color.FromArgb(103, 58, 183));
list.Add(Color.FromArgb(63, 81, 181)); list.Add(Color.FromArgb(63, 81, 181));
list.Add(Color.FromArgb(33, 150, 243)); list.Add(Color.FromArgb(33, 150, 243));
...@@ -828,6 +841,7 @@ namespace HZH_Controls ...@@ -828,6 +841,7 @@ namespace HZH_Controls
list.Add(Color.FromArgb(139, 195, 74)); list.Add(Color.FromArgb(139, 195, 74));
list.Add(Color.FromArgb(76, 175, 80)); list.Add(Color.FromArgb(76, 175, 80));
list.Add(Color.FromArgb(204, 219, 57)); list.Add(Color.FromArgb(204, 219, 57));
list.Add(Color.FromArgb(233, 30, 99));
list.Add(Color.FromArgb(254, 234, 59)); list.Add(Color.FromArgb(254, 234, 59));
list.Add(Color.FromArgb(254, 192, 7)); list.Add(Color.FromArgb(254, 192, 7));
list.Add(Color.FromArgb(254, 152, 0)); list.Add(Color.FromArgb(254, 152, 0));
...@@ -1368,6 +1382,6 @@ namespace HZH_Controls ...@@ -1368,6 +1382,6 @@ namespace HZH_Controls
} }
#endregion #endregion
} }
} }
...@@ -64,6 +64,7 @@ namespace Test ...@@ -64,6 +64,7 @@ namespace Test
tnControl.Nodes.Add("组织结构图"); tnControl.Nodes.Add("组织结构图");
tnCharts.Nodes.Add("滚动图表"); tnCharts.Nodes.Add("滚动图表");
tnCharts.Nodes.Add("柱状图"); tnCharts.Nodes.Add("柱状图");
tnCharts.Nodes.Add("饼状图");
this.tvMenu.Nodes.Add(tnCharts); this.tvMenu.Nodes.Add(tnCharts);
TreeNode tnFactory = new TreeNode(" 工业控件"); TreeNode tnFactory = new TreeNode(" 工业控件");
...@@ -209,7 +210,10 @@ namespace Test ...@@ -209,7 +210,10 @@ namespace Test
AddControl(new UC.UCTestMindMapping() { Dock = DockStyle.Fill }); AddControl(new UC.UCTestMindMapping() { Dock = DockStyle.Fill });
break; break;
case "柱状图": case "柱状图":
AddControl(new UC.UCTestBarcharts()); AddControl(new UC.UCTestBarcharts());
break;
case "饼状图":
AddControl(new UC.UCTestPieCharts());
break; break;
case "滚动图表": case "滚动图表":
AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill }); AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill });
......
...@@ -194,6 +194,12 @@ ...@@ -194,6 +194,12 @@
<Compile Include="UC\UCTestPanelTitle.Designer.cs"> <Compile Include="UC\UCTestPanelTitle.Designer.cs">
<DependentUpon>UCTestPanelTitle.cs</DependentUpon> <DependentUpon>UCTestPanelTitle.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UC\UCTestPieCharts.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestPieCharts.Designer.cs">
<DependentUpon>UCTestPieCharts.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestProcess.cs"> <Compile Include="UC\UCTestProcess.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -359,6 +365,9 @@ ...@@ -359,6 +365,9 @@
<EmbeddedResource Include="UC\UCTestPanelTitle.resx"> <EmbeddedResource Include="UC\UCTestPanelTitle.resx">
<DependentUpon>UCTestPanelTitle.cs</DependentUpon> <DependentUpon>UCTestPanelTitle.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UC\UCTestPieCharts.resx">
<DependentUpon>UCTestPieCharts.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestProcess.resx"> <EmbeddedResource Include="UC\UCTestProcess.resx">
<DependentUpon>UCTestProcess.cs</DependentUpon> <DependentUpon>UCTestProcess.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
namespace Test.UC
{
partial class UCTestPieCharts
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
HZH_Controls.Controls.PieItem pieItem1 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem2 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem3 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem4 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem5 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem6 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem7 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem8 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem9 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem10 = new HZH_Controls.Controls.PieItem();
this.ucPieChart1 = new HZH_Controls.Controls.UCPieChart();
this.ucPieChart2 = new HZH_Controls.Controls.UCPieChart();
this.SuspendLayout();
//
// ucPieChart1
//
this.ucPieChart1.BackColor = System.Drawing.Color.Transparent;
this.ucPieChart1.CenterOfCircleColor = System.Drawing.Color.White;
this.ucPieChart1.CenterOfCircleWidth = 0;
pieItem1.Name = "Source1";
pieItem1.PieColor = null;
pieItem1.Value = 27;
pieItem2.Name = "Source2";
pieItem2.PieColor = null;
pieItem2.Value = 20;
pieItem3.Name = "Source3";
pieItem3.PieColor = null;
pieItem3.Value = 94;
pieItem4.Name = "Source4";
pieItem4.PieColor = null;
pieItem4.Value = 28;
pieItem5.Name = "Source5";
pieItem5.PieColor = null;
pieItem5.Value = 84;
this.ucPieChart1.DataSource = new HZH_Controls.Controls.PieItem[] {
pieItem1,
pieItem2,
pieItem3,
pieItem4,
pieItem5};
this.ucPieChart1.IsRenderPercent = true;
this.ucPieChart1.Location = new System.Drawing.Point(50, 71);
this.ucPieChart1.Name = "ucPieChart1";
this.ucPieChart1.Size = new System.Drawing.Size(342, 298);
this.ucPieChart1.TabIndex = 1;
this.ucPieChart1.TiTle = null;
this.ucPieChart1.TitleFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucPieChart1.TitleFroeColor = System.Drawing.Color.Black;
//
// ucPieChart2
//
this.ucPieChart2.BackColor = System.Drawing.Color.Transparent;
this.ucPieChart2.CenterOfCircleColor = System.Drawing.Color.White;
this.ucPieChart2.CenterOfCircleWidth = 0;
pieItem6.Name = "Source1";
pieItem6.PieColor = null;
pieItem6.Value = 27;
pieItem7.Name = "Source2";
pieItem7.PieColor = null;
pieItem7.Value = 20;
pieItem8.Name = "Source3";
pieItem8.PieColor = null;
pieItem8.Value = 94;
pieItem9.Name = "Source4";
pieItem9.PieColor = null;
pieItem9.Value = 28;
pieItem10.Name = "Source5";
pieItem10.PieColor = null;
pieItem10.Value = 84;
this.ucPieChart2.DataSource = new HZH_Controls.Controls.PieItem[] {
pieItem6,
pieItem7,
pieItem8,
pieItem9,
pieItem10};
this.ucPieChart2.Location = new System.Drawing.Point(415, 20);
this.ucPieChart2.Name = "ucPieChart2";
this.ucPieChart2.Size = new System.Drawing.Size(395, 349);
this.ucPieChart2.TabIndex = 0;
this.ucPieChart2.TiTle = "有标题的饼状图";
this.ucPieChart2.TitleFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucPieChart2.TitleFroeColor = System.Drawing.Color.Black;
//
// UCTestPieCharts
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.ucPieChart1);
this.Controls.Add(this.ucPieChart2);
this.Name = "UCTestPieCharts";
this.Size = new System.Drawing.Size(813, 493);
this.Load += new System.EventHandler(this.UCTestPieCharts_Load);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCPieChart ucPieChart2;
private HZH_Controls.Controls.UCPieChart ucPieChart1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HZH_Controls.Controls;
namespace Test.UC
{
public partial class UCTestPieCharts : UserControl
{
public UCTestPieCharts()
{
InitializeComponent();
}
private void UCTestPieCharts_Load(object sender, EventArgs e)
{
Random r = new Random();
var pieItems = new PieItem[5];
for (int i = 0; i < 5; i++)
{
pieItems[i] = new PieItem
{
Name = "Source" + (i + 1),
Value = r.Next(10, 100)
};
}
this.ucPieChart1.SetDataSource(pieItems);
this.ucPieChart2.SetDataSource(pieItems);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!