* UIBarChartEx:增加显示名称及数值
This commit is contained in:
parent
c3ff5933ba
commit
942a596aec
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
SunnyUI.Demo/Charts/FBarChartEx.Designer.cs
generated
2
SunnyUI.Demo/Charts/FBarChartEx.Designer.cs
generated
@ -114,7 +114,7 @@
|
||||
this.uiLine1.Name = "uiLine1";
|
||||
this.uiLine1.Size = new System.Drawing.Size(670, 20);
|
||||
this.uiLine1.TabIndex = 30;
|
||||
this.uiLine1.Text = "UIBarChart";
|
||||
this.uiLine1.Text = "UIBarChartEx";
|
||||
this.uiLine1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// BarChart
|
||||
|
@ -27,6 +27,9 @@ namespace Sunny.UI.Demo
|
||||
private void uiSymbolButton1_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
UIBarOption option = new UIBarOption();
|
||||
|
||||
option.Grid.Bottom = 60;
|
||||
|
||||
option.Title = new UITitle();
|
||||
option.Title.Text = "SunnyUI";
|
||||
option.Title.SubText = "BarChartEx";
|
||||
@ -42,19 +45,25 @@ namespace Sunny.UI.Demo
|
||||
|
||||
var series = new UIBarSeries();
|
||||
series.Name = "Bar1";
|
||||
series.ShowBarName = true;
|
||||
series.ShowValue = true;
|
||||
series.AddData("通道1", 11);
|
||||
series.AddData("通道2", 15);
|
||||
option.Series.Add(series);
|
||||
|
||||
series = new UIBarSeries();
|
||||
series.Name = "Bar2";
|
||||
series.AddData("通道1", -22);
|
||||
series.AddData("通道2", -28);
|
||||
series.AddData("通道3", -25);
|
||||
series.ShowBarName = true;
|
||||
series.ShowValue = true;
|
||||
series.AddData("通道1", 22);
|
||||
series.AddData("通道2", 28);
|
||||
series.AddData("通道3", 25);
|
||||
option.Series.Add(series);
|
||||
|
||||
series = new UIBarSeries();
|
||||
series.Name = "Bar3";
|
||||
series.ShowBarName = true;
|
||||
series.ShowValue = true;
|
||||
series.AddData("通道1", 7);
|
||||
option.Series.Add(series);
|
||||
|
||||
@ -70,6 +79,8 @@ namespace Sunny.UI.Demo
|
||||
option.XAxis.Name = "日期";
|
||||
option.YAxis.Name = "数值";
|
||||
|
||||
option.XAxis.AxisTick.Distance = 14;
|
||||
|
||||
option.FixedSeriesCount = 3;
|
||||
|
||||
option.YAxisScaleLines.Add(new UIScaleLine() { Color = Color.Red, Name = "上限", Value = 12 });
|
||||
|
120
SunnyUI.Demo/Charts/FBarChartEx.resx
Normal file
120
SunnyUI.Demo/Charts/FBarChartEx.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
@ -301,6 +301,9 @@
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Charts\FBarChartEx.resx">
|
||||
<DependentUpon>FBarChartEx.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Controls\FAvatar.resx">
|
||||
<DependentUpon>FAvatar.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -158,7 +158,7 @@ namespace Sunny.UI
|
||||
for (int j = 0; j < series.Data.Count; j++)
|
||||
{
|
||||
str += '\n';
|
||||
if (series.BarName.Count >= 0 && j < series.BarName.Count)
|
||||
if (series.BarName.Count > 0 && j < series.BarName.Count)
|
||||
str += series.BarName[j] + " : ";
|
||||
|
||||
str += series.Data[j].ToString(BarOption.ToolTip.ValueFormat);
|
||||
@ -176,9 +176,39 @@ namespace Sunny.UI
|
||||
for (int i = 0; i < Bars.Count; i++)
|
||||
{
|
||||
var bars = Bars[i];
|
||||
foreach (var info in bars)
|
||||
for (int j = 0; j < bars.Count; j++)
|
||||
{
|
||||
g.FillRectangle(info.Color, info.Rect);
|
||||
g.FillRectangle(bars[j].Color, bars[j].Rect);
|
||||
var s = BarOption.Series[i];
|
||||
if (s.ShowBarName)
|
||||
{
|
||||
if (s.BarName.Count > 0 && j < s.BarName.Count)
|
||||
{
|
||||
SizeF sf = g.MeasureString(s.BarName[j], SubFont);
|
||||
if (s.Data[j] >= 0)
|
||||
g.DrawString(s.BarName[j], SubFont, ChartStyle.ForeColor,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Bottom + 1);
|
||||
else
|
||||
g.DrawString(s.BarName[j], SubFont, ChartStyle.ForeColor,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Top - sf.Height);
|
||||
}
|
||||
}
|
||||
|
||||
if (s.ShowValue)
|
||||
{
|
||||
string value = s.Data[j].ToString("F" + BarOption.XAxis.AxisLabel.DecimalCount);
|
||||
SizeF sf = g.MeasureString(value, SubFont);
|
||||
if (s.Data[j] < 0)
|
||||
g.DrawString(value, SubFont, bars[j].Color,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Bottom + 1);
|
||||
else
|
||||
g.DrawString(value, SubFont, bars[j].Color,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Top - sf.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,12 +268,12 @@ namespace Sunny.UI
|
||||
foreach (var data in BarOption.Series)
|
||||
{
|
||||
SizeF sf = g.MeasureString(data.Name, SubFont);
|
||||
g.DrawString(data.Name, SubFont, ChartStyle.ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length);
|
||||
g.DrawString(data.Name, SubFont, ChartStyle.ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length + BarOption.XAxis.AxisTick.Distance);
|
||||
start += DrawBarWidth;
|
||||
}
|
||||
|
||||
SizeF sfName = g.MeasureString(BarOption.XAxis.Name, SubFont);
|
||||
g.DrawString(BarOption.XAxis.Name, SubFont, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length + sfName.Height);
|
||||
g.DrawString(BarOption.XAxis.Name, SubFont, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length + BarOption.XAxis.AxisTick.Distance + sfName.Height);
|
||||
}
|
||||
|
||||
if (BarOption.YAxis.AxisTick.Show)
|
||||
|
@ -179,6 +179,8 @@ namespace Sunny.UI
|
||||
/// 如果设置为 1,表示『隔一个标签显示一个标签』,如果值为 2,表示隔两个标签显示一个标签,以此类推。
|
||||
/// </summary>
|
||||
public int Interval { get; set; } = 0;
|
||||
|
||||
public int Distance { get; set; } = 0;
|
||||
}
|
||||
|
||||
public class UIValueAxis : UIAxis
|
||||
@ -203,6 +205,10 @@ namespace Sunny.UI
|
||||
|
||||
public readonly List<Color> Colors = new List<Color>();
|
||||
|
||||
public bool ShowBarName { get; set; }
|
||||
|
||||
public bool ShowValue { get; set; }
|
||||
|
||||
public void AddData(double value)
|
||||
{
|
||||
Data.Add(value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user