完善ECharts系列图类型,优化系列图的创建
This commit is contained in:
parent
3e2fc9bc32
commit
2f96210a70
|
@ -288,7 +288,7 @@ public class ECharts : IExtend
|
|||
var p2 = formatterScript.IndexOf('(', p);
|
||||
if (p2 < 0) throw new ArgumentOutOfRangeException(nameof(formatterScript), "无效js函数");
|
||||
|
||||
var name = formatterScript.Substring(p, p2 - p).Trim();
|
||||
var name = formatterScript[p..p2].Trim();
|
||||
|
||||
var tooltip = new Tooltip
|
||||
{
|
||||
|
@ -373,7 +373,8 @@ public class ECharts : IExtend
|
|||
Series.Add(series);
|
||||
}
|
||||
|
||||
private Series Create(String name, String type, Object[] data = null)
|
||||
/// <summary>创建系列</summary>
|
||||
public Series Create(String name, String type, Object[] data = null)
|
||||
{
|
||||
if (type.IsNullOrEmpty()) type = "line";
|
||||
var sr = type switch
|
||||
|
@ -404,6 +405,41 @@ public class ECharts : IExtend
|
|||
return sr;
|
||||
}
|
||||
|
||||
/// <summary>创建系列图</summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public Series Create(String name, SeriesTypes type, Object[] data = null)
|
||||
{
|
||||
var sr = type switch
|
||||
{
|
||||
SeriesTypes.Line => new SeriesLine(),
|
||||
SeriesTypes.Line3D => new SeriesLine3D(),
|
||||
SeriesTypes.Lines => new SeriesLines(),
|
||||
SeriesTypes.Lines3D => new SeriesLines3D(),
|
||||
SeriesTypes.Bar => new SeriesBar(),
|
||||
SeriesTypes.Bar3D => new SeriesBar3D(),
|
||||
SeriesTypes.Pie => new SeriesPie(),
|
||||
SeriesTypes.Graph => new SeriesGraph(),
|
||||
SeriesTypes.Scatter or SeriesTypes.EffectScatter => new SeriesEffectScatter(),
|
||||
SeriesTypes.Boxplot => new SeriesBoxplot(),
|
||||
SeriesTypes.Radar => new SeriesRadar(),
|
||||
SeriesTypes.Funnel => new SeriesFunnel(),
|
||||
SeriesTypes.Gauge => new SeriesGauge(),
|
||||
SeriesTypes.Tree => new SeriesTree(),
|
||||
SeriesTypes.Treemap => new SeriesTreemap(),
|
||||
SeriesTypes.Heatmap => new SeriesHeatmap(),
|
||||
SeriesTypes.Sunburst => new SeriesSunburst(),
|
||||
SeriesTypes.Sankey => new SeriesSankey(),
|
||||
_ => new Series { Type = type.ToString().ToLower() },
|
||||
};
|
||||
sr.Name = name;
|
||||
sr.Data = data;
|
||||
|
||||
return sr;
|
||||
}
|
||||
|
||||
/// <summary>添加系列数据</summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list">实体列表</param>
|
||||
|
@ -464,7 +500,7 @@ public class ECharts : IExtend
|
|||
list.Select(e => new Object[] { GetTimeValue(e), selector == null ? e[field.Name] : selector(e) }).ToArray() :
|
||||
list.Select(e => selector == null ? e[field.Name] : selector(e)).ToArray();
|
||||
|
||||
var sr = Create(field?.DisplayName ?? field.Name, type.ToString().ToLower(), data);
|
||||
var sr = Create(field?.DisplayName ?? field.Name, type, data);
|
||||
|
||||
if (!Symbol.IsNullOrEmpty()) sr.Symbol = Symbol;
|
||||
|
||||
|
@ -497,7 +533,7 @@ public class ECharts : IExtend
|
|||
list.Select(e => new Object[] { GetTimeValue(e), selector == null ? e[field.Name] : selector(e) }).ToArray() :
|
||||
list.Select(e => selector == null ? e[field.Name] : selector(e)).ToArray();
|
||||
|
||||
series = Create(field?.DisplayName ?? field.Name, type.ToString().ToLower(), data);
|
||||
series = Create(field?.DisplayName ?? field.Name, type, data);
|
||||
|
||||
if (!Symbol.IsNullOrEmpty()) series.Symbol = Symbol;
|
||||
|
||||
|
@ -638,16 +674,16 @@ public class ECharts : IExtend
|
|||
return sr;
|
||||
}
|
||||
|
||||
/// <summary>添加图形。有向图/引力图</summary>
|
||||
/// <summary>添加关系图。有向图/引力图</summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public Series AddGraph(GraphViewModel model)
|
||||
{
|
||||
var graph = Create(model.Title, "graph");
|
||||
graph["Layout"] = model.Layout;
|
||||
var graph = Create(model.Title, SeriesTypes.Graph) as SeriesGraph;
|
||||
graph.Layout = model.Layout;
|
||||
if (model.Layout == "force")
|
||||
{
|
||||
graph["Force"] = new
|
||||
graph.Force = new
|
||||
{
|
||||
initLayout = "circular",
|
||||
Repulsion = 300,
|
||||
|
@ -658,16 +694,16 @@ public class ECharts : IExtend
|
|||
};
|
||||
}
|
||||
|
||||
graph["edgeSymbol"] = new[] { "circle", "arrow" };
|
||||
graph["edgeSymbolSize"] = new[] { 4, 10 };
|
||||
graph["roam"] = true;
|
||||
graph["label"] = new { show = true, position = "right" };
|
||||
graph["labelLayout"] = new { hideOverlap = true, moveOverlap = true };
|
||||
graph["lineStyle"] = new { color = "target", curveness = 0.3, opacity = 0.8, width = 3 };
|
||||
graph.EdgeSymbol = new[] { "circle", "arrow" };
|
||||
graph.EdgeSymbolSize = new[] { 4, 10 };
|
||||
graph.Roam = true;
|
||||
graph.Label = new { show = true, position = "right" };
|
||||
graph.LabelLayout = new { hideOverlap = true, moveOverlap = true };
|
||||
graph.LineStyle = new { color = "target", curveness = 0.3, opacity = 0.8, width = 3 };
|
||||
|
||||
graph.Data = model.Nodes;
|
||||
graph["links"] = model.Links;
|
||||
graph["categories"] = model.Categories;
|
||||
graph.Links = model.Links;
|
||||
graph.Categories = model.Categories;
|
||||
|
||||
Legend = new { Data = model.Categories.Select(e => e.Name).ToArray() };
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
/// </remark>
|
||||
public class SeriesBar : Series
|
||||
{
|
||||
/// <summary>实例化柱状图</summary>
|
||||
public SeriesBar() => Type = "bar";
|
||||
|
||||
//public String Type { get; set; } = "bar";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
/// </remark>
|
||||
public class SeriesBar3D : Series
|
||||
{
|
||||
/// <summary>实例化3D柱状图</summary>
|
||||
public SeriesBar3D() => Type = "bar3D";
|
||||
|
||||
//public String Type { get; set; } = "bar3D";
|
||||
|
||||
///// <summary></summary>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
/// </remark>
|
||||
public class SeriesBoxplot : Series
|
||||
{
|
||||
/// <summary>实例化箱形图</summary>
|
||||
public SeriesBoxplot() => Type = "boxplot";
|
||||
|
||||
//public String Type { get; set; } = "boxplot";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
/// </remark>
|
||||
public class SeriesEffectScatter : Series
|
||||
{
|
||||
/// <summary>实例化散点图</summary>
|
||||
public SeriesEffectScatter() => Type = "effectScatter";
|
||||
|
||||
//public String Type { get; set; } = "effectScatter";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
/// <summary>漏斗图</summary>
|
||||
public class SeriesFunnel : Series
|
||||
{
|
||||
/// <summary>实例化漏斗图</summary>
|
||||
public SeriesFunnel() => Type = "funnel";
|
||||
|
||||
//public String Type { get; set; } = "funnel";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
/// </remark>
|
||||
public class SeriesGauge : Series
|
||||
{
|
||||
/// <summary>实例化仪表盘</summary>
|
||||
public SeriesGauge() => Type = "gauge";
|
||||
|
||||
//public String Type { get; set; } = "gauge";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
namespace NewLife.Cube.Charts;
|
||||
|
||||
/// <summary></summary>
|
||||
/// <summary>关系图</summary>
|
||||
/// <remark>
|
||||
/// 关系图
|
||||
/// 用于展现节点以及节点之间的关系数据。
|
||||
/// 示例:
|
||||
/// </remark>
|
||||
public class SeriesGraph : Series
|
||||
{
|
||||
/// <summary>实例化关系图</summary>
|
||||
public SeriesGraph() => Type = "graph";
|
||||
|
||||
//public String Type { get; set; } = "graph";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
/// </remark>
|
||||
public class SeriesHeatmap : Series
|
||||
{
|
||||
/// <summary>实例化热力图</summary>
|
||||
public SeriesHeatmap() => Type = "heatmap";
|
||||
|
||||
//public String Type { get; set; } = "heatmap";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
/// </remark>
|
||||
public class SeriesLine : Series
|
||||
{
|
||||
/// <summary>初始化</summary>
|
||||
public SeriesLine() => Type = "line";
|
||||
|
||||
//public String Type { get; set; } = "line";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
/// <remark>可以用于三维直角坐标系 grid3D。</remark>
|
||||
public class SeriesLine3D : Series
|
||||
{
|
||||
/// <summary>实例化三维折线图</summary>
|
||||
public SeriesLine3D() => Type = "line3D";
|
||||
|
||||
//public String Type { get; set; } = "line3D";
|
||||
|
||||
///// <summary></summary>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
/// </remark>
|
||||
public class SeriesLines : Series
|
||||
{
|
||||
/// <summary>实例化路径图</summary>
|
||||
public SeriesLines() => Type = "lines";
|
||||
|
||||
//public String Type { get; set; } = "lines";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
/// </remark>
|
||||
public class SeriesLines3D : Series
|
||||
{
|
||||
/// <summary>实例化三维飞线图</summary>
|
||||
public SeriesLines3D() => Type = "lines3D";
|
||||
|
||||
//public String Type { get; set; } = "lines3D";
|
||||
|
||||
///// <summary></summary>
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
/// </remark>
|
||||
public class SeriesPie : Series
|
||||
{
|
||||
/// <summary>实例化饼图</summary>
|
||||
public SeriesPie() => Type = "pie";
|
||||
|
||||
//public String Type { get; set; } = "pie";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
/// </remark>
|
||||
public class SeriesRadar : Series
|
||||
{
|
||||
/// <summary>实例化雷达图</summary>
|
||||
public SeriesRadar() => Type = "radar";
|
||||
|
||||
//public String Type { get; set; } = "radar";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
/// </remark>
|
||||
public class SeriesSankey : Series
|
||||
{
|
||||
/// <summary>实例化桑基图</summary>
|
||||
public SeriesSankey() => Type = "sankey";
|
||||
|
||||
//public String Type { get; set; } = "sankey";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
/// </remark>
|
||||
public class SeriesSunburst : Series
|
||||
{
|
||||
/// <summary>实例化旭日图</summary>
|
||||
public SeriesSunburst() => Type = "sunburst";
|
||||
|
||||
//public String Type { get; set; } = "sunburst";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
/// </remark>
|
||||
public class SeriesTree : Series
|
||||
{
|
||||
/// <summary>实例化树图</summary>
|
||||
public SeriesTree() => Type = "tree";
|
||||
|
||||
//public String Type { get; set; } = "tree";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
/// </remark>
|
||||
public class SeriesTreemap : Series
|
||||
{
|
||||
/// <summary>实例化矩形树图</summary>
|
||||
public SeriesTreemap() => Type = "treemap";
|
||||
|
||||
//public String Type { get; set; } = "treemap";
|
||||
|
||||
///// <summary>组件 ID</summary>
|
||||
|
|
|
@ -4,26 +4,59 @@
|
|||
public enum SeriesTypes
|
||||
{
|
||||
/// <summary>折线图</summary>
|
||||
Line,
|
||||
Line = 1,
|
||||
|
||||
/// <summary>三维折线图</summary>
|
||||
Line3D,
|
||||
|
||||
/// <summary>路径图</summary>
|
||||
Lines,
|
||||
|
||||
/// <summary>三维飞线图</summary>
|
||||
Lines3D,
|
||||
|
||||
/// <summary>柱状图</summary>
|
||||
Bar,
|
||||
|
||||
/// <summary>三维柱状图</summary>
|
||||
Bar3D,
|
||||
|
||||
/// <summary>饼图</summary>
|
||||
Pie,
|
||||
|
||||
/// <summary>散点图</summary>
|
||||
Scatter,
|
||||
|
||||
/// <summary>关系图</summary>
|
||||
Graph,
|
||||
|
||||
/// <summary>散点图</summary>
|
||||
Scatter,
|
||||
|
||||
/// <summary>气泡散点图</summary>
|
||||
EffectScatter,
|
||||
|
||||
/// <summary>箱形图</summary>
|
||||
Boxplot,
|
||||
|
||||
/// <summary>雷达图</summary>
|
||||
Radar,
|
||||
|
||||
/// <summary>漏斗图</summary>
|
||||
Funnel,
|
||||
|
||||
/// <summary>仪表盘</summary>
|
||||
Gauge,
|
||||
|
||||
/// <summary>树图</summary>
|
||||
Tree,
|
||||
|
||||
/// <summary>层级数据</summary>
|
||||
/// <summary>矩形树图</summary>
|
||||
Treemap,
|
||||
|
||||
/// <summary>热力图</summary>
|
||||
Heatmap,
|
||||
|
||||
/// <summary>旭日图</summary>
|
||||
Sunburst,
|
||||
|
||||
/// <summary>桑基图</summary>
|
||||
Sankey,
|
||||
}
|
Loading…
Reference in New Issue