jmchart 1.2.16 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -37
- package/dist/jmchart.amd.js +135 -271
- package/dist/jmchart.cjs.js +135 -271
- package/dist/jmchart.esm.js +135 -271
- package/dist/jmchart.iife.js +135 -271
- package/dist/jmchart.system.js +135 -271
- package/index.d.ts +498 -0
- package/package.json +3 -2
- package/src/common/style.js +0 -21
- package/src/jmChart.js +1 -3
- package/src/series/gaugeSeries.js +19 -12
- package/src/series/lineSeries.js +111 -11
- package/src/series/ringProgressSeries.js +5 -3
- package/src/series/sunburstSeries.js +0 -240
package/dist/jmchart.iife.js
CHANGED
|
@@ -9661,27 +9661,6 @@ var jmChart = (function (exports) {
|
|
|
9661
9661
|
spiral: true,
|
|
9662
9662
|
zIndex: 11,
|
|
9663
9663
|
cursor: 'default'
|
|
9664
|
-
},
|
|
9665
|
-
sunburst: {
|
|
9666
|
-
normal: {
|
|
9667
|
-
zIndex: 11,
|
|
9668
|
-
cursor: 'default'
|
|
9669
|
-
},
|
|
9670
|
-
hover: {
|
|
9671
|
-
cursor: 'pointer'
|
|
9672
|
-
},
|
|
9673
|
-
innerRadius: 0,
|
|
9674
|
-
startAngle: 0,
|
|
9675
|
-
showLabels: true,
|
|
9676
|
-
showCenter: true,
|
|
9677
|
-
centerFill: '#fff',
|
|
9678
|
-
centerStroke: '#e0e0e0',
|
|
9679
|
-
stroke: '#fff',
|
|
9680
|
-
lineWidth: 1,
|
|
9681
|
-
labelColor: '#fff',
|
|
9682
|
-
labelFont: '12px Arial',
|
|
9683
|
-
zIndex: 11,
|
|
9684
|
-
cursor: 'default'
|
|
9685
9664
|
}
|
|
9686
9665
|
};
|
|
9687
9666
|
|
|
@@ -11990,10 +11969,42 @@ var jmChart = (function (exports) {
|
|
|
11990
11969
|
this.graph.legend.append(this, shape);
|
|
11991
11970
|
}
|
|
11992
11971
|
|
|
11993
|
-
//
|
|
11994
|
-
createArea(points
|
|
11972
|
+
// 生成面积效果
|
|
11973
|
+
createArea(points) {
|
|
11995
11974
|
// 有指定绘制区域效果才展示
|
|
11996
11975
|
if (!this.style.area || points.length < 2) return;
|
|
11976
|
+
|
|
11977
|
+
// 基线:取X轴的实际Y位置(chartArea相对坐标),没有X轴时用下边界
|
|
11978
|
+
const axisY = this.graph.xAxis ? this.graph.xAxis.start.y - this.graph.chartArea.position.y : this.graph.chartArea.height;
|
|
11979
|
+
|
|
11980
|
+
// 过滤有效点
|
|
11981
|
+
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
11982
|
+
if (validPoints.length < 2) return;
|
|
11983
|
+
|
|
11984
|
+
// 检测所有点是否在基线的同一侧
|
|
11985
|
+
// y < axisY 表示在基线上方(数据值大于基线值),y > axisY 表示在基线下方
|
|
11986
|
+
let allAbove = true;
|
|
11987
|
+
let allBelow = true;
|
|
11988
|
+
for (const p of validPoints) {
|
|
11989
|
+
if (p.y <= axisY) allBelow = false;
|
|
11990
|
+
if (p.y >= axisY) allAbove = false;
|
|
11991
|
+
}
|
|
11992
|
+
if (allAbove || allBelow) {
|
|
11993
|
+
// 全部在基线同侧:创建单个封闭区域
|
|
11994
|
+
this._createAreaSegment(points, allAbove, axisY);
|
|
11995
|
+
} else {
|
|
11996
|
+
// 混合数据:在交叉点处分割,分别创建封闭区域
|
|
11997
|
+
this._createMixedAreas(points, axisY);
|
|
11998
|
+
}
|
|
11999
|
+
}
|
|
12000
|
+
|
|
12001
|
+
/**
|
|
12002
|
+
* 创建单个面积段
|
|
12003
|
+
* @param {Array} points 线条上的点
|
|
12004
|
+
* @param {boolean} isAbove 是否在基线上方
|
|
12005
|
+
* @param {number} axisY 基线Y坐标(chartArea相对坐标)
|
|
12006
|
+
*/
|
|
12007
|
+
_createAreaSegment(points, isAbove, axisY) {
|
|
11997
12008
|
const start = points[0];
|
|
11998
12009
|
const end = points[points.length - 1];
|
|
11999
12010
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
@@ -12001,12 +12012,21 @@ var jmChart = (function (exports) {
|
|
|
12001
12012
|
style.stroke = style.stroke || 'transparent';
|
|
12002
12013
|
if (!style.fill) {
|
|
12003
12014
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12015
|
+
if (isAbove) {
|
|
12016
|
+
// 基线上方:渐变从线条处(顶部)不透明到基线处(底部)透明
|
|
12017
|
+
style.fill = `linear-gradient(50% 0 50% 100%,
|
|
12018
|
+
rgba(${color.r},${color.g},${color.b}, 0) 1,
|
|
12019
|
+
rgba(${color.r},${color.g},${color.b}, 0.1) 0.7,
|
|
12020
|
+
rgba(${color.r},${color.g},${color.b}, 0.3) 0)`;
|
|
12021
|
+
} else {
|
|
12022
|
+
// 基线下方:渐变从基线处(顶部)透明到线条处(底部)不透明
|
|
12023
|
+
style.fill = `linear-gradient(50% 0 50% 100%,
|
|
12024
|
+
rgba(${color.r},${color.g},${color.b}, 0.3) 1,
|
|
12025
|
+
rgba(${color.r},${color.g},${color.b}, 0.1) 0.3,
|
|
12026
|
+
rgba(${color.r},${color.g},${color.b}, 0) 0)`;
|
|
12027
|
+
}
|
|
12008
12028
|
} else if (typeof style.fill === 'function') {
|
|
12009
|
-
style.fill = style.fill.call(this, style);
|
|
12029
|
+
style.fill = style.fill.call(this, style, isAbove);
|
|
12010
12030
|
}
|
|
12011
12031
|
const area = this.graph.createShape('path', {
|
|
12012
12032
|
points: this.graph.utils.clone(points, true),
|
|
@@ -12015,19 +12035,78 @@ var jmChart = (function (exports) {
|
|
|
12015
12035
|
height: this.graph.chartArea.height
|
|
12016
12036
|
});
|
|
12017
12037
|
|
|
12018
|
-
//
|
|
12019
|
-
|
|
12038
|
+
// 在首尾加上基线上的点,组成封闭多边形
|
|
12039
|
+
// 如果首/尾点已经在基线上(交叉点),则不重复添加
|
|
12040
|
+
if (Math.abs(start.y - axisY) > 0.5) {
|
|
12020
12041
|
area.points.unshift({
|
|
12021
12042
|
x: start.x,
|
|
12022
|
-
y:
|
|
12043
|
+
y: axisY
|
|
12023
12044
|
});
|
|
12045
|
+
}
|
|
12046
|
+
if (Math.abs(end.y - axisY) > 0.5) {
|
|
12024
12047
|
area.points.push({
|
|
12025
12048
|
x: end.x,
|
|
12026
|
-
y:
|
|
12049
|
+
y: axisY
|
|
12027
12050
|
});
|
|
12028
12051
|
}
|
|
12029
12052
|
this.addShape(area);
|
|
12030
12053
|
}
|
|
12054
|
+
|
|
12055
|
+
/**
|
|
12056
|
+
* 处理跨基线的混合数据,在交叉点处分割成多个独立区域
|
|
12057
|
+
* @param {Array} points 线条上的点
|
|
12058
|
+
* @param {number} axisY 基线Y坐标(chartArea相对坐标)
|
|
12059
|
+
*/
|
|
12060
|
+
_createMixedAreas(points, axisY) {
|
|
12061
|
+
const segments = [];
|
|
12062
|
+
let currentSegment = [];
|
|
12063
|
+
let prevAbove = null;
|
|
12064
|
+
for (let i = 0; i < points.length; i++) {
|
|
12065
|
+
const p = points[i];
|
|
12066
|
+
if (p.y == null || typeof p.y === 'undefined') continue;
|
|
12067
|
+
const isAbove = p.y < axisY;
|
|
12068
|
+
if (currentSegment.length === 0) {
|
|
12069
|
+
currentSegment.push(p);
|
|
12070
|
+
prevAbove = isAbove;
|
|
12071
|
+
} else if (isAbove === prevAbove) {
|
|
12072
|
+
currentSegment.push(p);
|
|
12073
|
+
} else {
|
|
12074
|
+
// 检测到跨基线交叉:计算交叉点
|
|
12075
|
+
const prev = currentSegment[currentSegment.length - 1];
|
|
12076
|
+
const t = (axisY - prev.y) / (p.y - prev.y);
|
|
12077
|
+
const crossPoint = {
|
|
12078
|
+
x: prev.x + (p.x - prev.x) * t,
|
|
12079
|
+
y: axisY
|
|
12080
|
+
};
|
|
12081
|
+
|
|
12082
|
+
// 当前段在交叉点处结束
|
|
12083
|
+
currentSegment.push(crossPoint);
|
|
12084
|
+
if (currentSegment.length >= 2) {
|
|
12085
|
+
segments.push({
|
|
12086
|
+
points: [...currentSegment],
|
|
12087
|
+
above: prevAbove
|
|
12088
|
+
});
|
|
12089
|
+
}
|
|
12090
|
+
|
|
12091
|
+
// 新段从交叉点开始
|
|
12092
|
+
currentSegment = [crossPoint, p];
|
|
12093
|
+
prevAbove = isAbove;
|
|
12094
|
+
}
|
|
12095
|
+
}
|
|
12096
|
+
|
|
12097
|
+
// 最后一段
|
|
12098
|
+
if (currentSegment.length >= 2) {
|
|
12099
|
+
segments.push({
|
|
12100
|
+
points: currentSegment,
|
|
12101
|
+
above: prevAbove
|
|
12102
|
+
});
|
|
12103
|
+
}
|
|
12104
|
+
|
|
12105
|
+
// 为每段创建独立的面积
|
|
12106
|
+
for (const seg of segments) {
|
|
12107
|
+
this._createAreaSegment(seg.points, seg.above, axisY);
|
|
12108
|
+
}
|
|
12109
|
+
}
|
|
12031
12110
|
}
|
|
12032
12111
|
|
|
12033
12112
|
/**
|
|
@@ -12695,8 +12774,10 @@ var jmChart = (function (exports) {
|
|
|
12695
12774
|
const value = typeof p.yValue === 'number' ? p.yValue : 0;
|
|
12696
12775
|
const min = this.style.min || 0;
|
|
12697
12776
|
const max = this.style.max || 100;
|
|
12698
|
-
|
|
12699
|
-
const
|
|
12777
|
+
// 度数转弧度(jmArc 内部使用弧度)
|
|
12778
|
+
const DEG = Math.PI / 180;
|
|
12779
|
+
const startAngle = (this.style.startAngle || -150) * DEG;
|
|
12780
|
+
const endAngle = (this.style.endAngle || 150) * DEG;
|
|
12700
12781
|
const angleRange = endAngle - startAngle;
|
|
12701
12782
|
const normalizedValue = Math.max(min, Math.min(max, value));
|
|
12702
12783
|
const ratio = (normalizedValue - min) / (max - min);
|
|
@@ -12777,10 +12858,10 @@ var jmChart = (function (exports) {
|
|
|
12777
12858
|
for (let i = 0; i < tickCount; i++) {
|
|
12778
12859
|
const angle = startAngle + angleStep * i;
|
|
12779
12860
|
const value = min + (max - min) / (tickCount - 1) * i;
|
|
12780
|
-
const tickStartX = centerX + Math.cos(angle
|
|
12781
|
-
const tickStartY = centerY + Math.sin(angle
|
|
12782
|
-
const tickEndX = centerX + Math.cos(angle
|
|
12783
|
-
const tickEndY = centerY + Math.sin(angle
|
|
12861
|
+
const tickStartX = centerX + Math.cos(angle) * (radius - 30);
|
|
12862
|
+
const tickStartY = centerY + Math.sin(angle) * (radius - 30);
|
|
12863
|
+
const tickEndX = centerX + Math.cos(angle) * (radius - 10);
|
|
12864
|
+
const tickEndY = centerY + Math.sin(angle) * (radius - 10);
|
|
12784
12865
|
const tickLine = this.graph.createShape('line', {
|
|
12785
12866
|
style: {
|
|
12786
12867
|
stroke: this.style.tickColor || '#666',
|
|
@@ -12797,8 +12878,8 @@ var jmChart = (function (exports) {
|
|
|
12797
12878
|
}
|
|
12798
12879
|
});
|
|
12799
12880
|
this.addShape(tickLine);
|
|
12800
|
-
const labelX = centerX + Math.cos(angle
|
|
12801
|
-
const labelY = centerY + Math.sin(angle
|
|
12881
|
+
const labelX = centerX + Math.cos(angle) * (radius - 45);
|
|
12882
|
+
const labelY = centerY + Math.sin(angle) * (radius - 45);
|
|
12802
12883
|
const tickLabel = this.graph.createShape('label', {
|
|
12803
12884
|
style: {
|
|
12804
12885
|
fill: this.style.tickLabelColor || '#333',
|
|
@@ -12811,7 +12892,7 @@ var jmChart = (function (exports) {
|
|
|
12811
12892
|
x: labelX,
|
|
12812
12893
|
y: labelY
|
|
12813
12894
|
},
|
|
12814
|
-
text: value.toString()
|
|
12895
|
+
text: Number(value.toFixed(2)).toString()
|
|
12815
12896
|
});
|
|
12816
12897
|
this.addShape(tickLabel);
|
|
12817
12898
|
}
|
|
@@ -12822,8 +12903,8 @@ var jmChart = (function (exports) {
|
|
|
12822
12903
|
*/
|
|
12823
12904
|
createGaugePointer(centerX, centerY, radius, angle) {
|
|
12824
12905
|
const pointerLength = radius * 0.7;
|
|
12825
|
-
const pointerX = centerX + Math.cos(angle
|
|
12826
|
-
const pointerY = centerY + Math.sin(angle
|
|
12906
|
+
const pointerX = centerX + Math.cos(angle) * pointerLength;
|
|
12907
|
+
const pointerY = centerY + Math.sin(angle) * pointerLength;
|
|
12827
12908
|
const pointerLine = this.graph.createShape('line', {
|
|
12828
12909
|
style: {
|
|
12829
12910
|
stroke: this.style.pointerColor || '#333',
|
|
@@ -12865,6 +12946,10 @@ var jmChart = (function (exports) {
|
|
|
12865
12946
|
* 创建仪表盘值标签
|
|
12866
12947
|
*/
|
|
12867
12948
|
createGaugeValueLabel(centerX, centerY, radius, value) {
|
|
12949
|
+
// 使用 itemLabelFormat 格式化,如果没有则默认最多保留2位小数
|
|
12950
|
+
const text = this.option.itemLabelFormat ? this.option.itemLabelFormat.call(this, {
|
|
12951
|
+
yValue: value
|
|
12952
|
+
}) : Number(value.toFixed(2)).toString();
|
|
12868
12953
|
const valueLabel = this.graph.createShape('label', {
|
|
12869
12954
|
style: {
|
|
12870
12955
|
fill: this.style.valueColor || '#333',
|
|
@@ -12877,7 +12962,7 @@ var jmChart = (function (exports) {
|
|
|
12877
12962
|
x: centerX,
|
|
12878
12963
|
y: centerY + radius * 0.3
|
|
12879
12964
|
},
|
|
12880
|
-
text:
|
|
12965
|
+
text: text
|
|
12881
12966
|
});
|
|
12882
12967
|
this.addShape(valueLabel);
|
|
12883
12968
|
if (this.style.unit) {
|
|
@@ -13362,7 +13447,9 @@ var jmChart = (function (exports) {
|
|
|
13362
13447
|
const centerY = chartHeight / 2;
|
|
13363
13448
|
const maxRadius = Math.min(chartWidth, chartHeight) / 2 - 20;
|
|
13364
13449
|
const lineWidth = this.style.lineWidth || 20;
|
|
13365
|
-
|
|
13450
|
+
// 角度转弧度(jmArc 内部使用弧度)
|
|
13451
|
+
const DEG = Math.PI / 180;
|
|
13452
|
+
const startAngle = (this.style.startAngle !== undefined ? this.style.startAngle : -90) * DEG;
|
|
13366
13453
|
const maxValue = this.style.max || 100;
|
|
13367
13454
|
const field = this.field || 'value';
|
|
13368
13455
|
const len = data.length;
|
|
@@ -13400,7 +13487,7 @@ var jmChart = (function (exports) {
|
|
|
13400
13487
|
},
|
|
13401
13488
|
radius: radius,
|
|
13402
13489
|
startAngle: 0,
|
|
13403
|
-
endAngle:
|
|
13490
|
+
endAngle: Math.PI * 2
|
|
13404
13491
|
});
|
|
13405
13492
|
this.addShape(bgArc);
|
|
13406
13493
|
}
|
|
@@ -13411,7 +13498,7 @@ var jmChart = (function (exports) {
|
|
|
13411
13498
|
createRingProgress(centerX, centerY, radius, lineWidth, startAngle, ratio, index) {
|
|
13412
13499
|
if (ratio <= 0) return;
|
|
13413
13500
|
const color = this.getColor(null, index);
|
|
13414
|
-
const endAngle = startAngle + ratio *
|
|
13501
|
+
const endAngle = startAngle + ratio * Math.PI * 2;
|
|
13415
13502
|
const progressArc = this.graph.createShape('arc', {
|
|
13416
13503
|
style: {
|
|
13417
13504
|
stroke: color,
|
|
@@ -13967,228 +14054,6 @@ var jmChart = (function (exports) {
|
|
|
13967
14054
|
}
|
|
13968
14055
|
}
|
|
13969
14056
|
|
|
13970
|
-
/**
|
|
13971
|
-
* 旭日图
|
|
13972
|
-
*
|
|
13973
|
-
* 旭日图用于展示层级数据的占比关系,由多个同心圆环组成,每个圆环代表一个层级。
|
|
13974
|
-
* 内层圆环是外层圆环的父级,扇形角度代表数据占比。
|
|
13975
|
-
*
|
|
13976
|
-
* 数据格式要求:
|
|
13977
|
-
* - 树形结构数据,每个节点包含 name、value 和 children
|
|
13978
|
-
*
|
|
13979
|
-
* 样式配置:
|
|
13980
|
-
* - innerRadius: 内圆半径,默认 0
|
|
13981
|
-
* - startAngle: 起始角度,默认 0
|
|
13982
|
-
* - showLabels: 是否显示标签,默认 true
|
|
13983
|
-
*
|
|
13984
|
-
* @class jmSunburstSeries
|
|
13985
|
-
* @module jmChart
|
|
13986
|
-
* @extends jmSeries
|
|
13987
|
-
*
|
|
13988
|
-
* @example
|
|
13989
|
-
* chart.createSeries('sunburst', {
|
|
13990
|
-
* data: [{
|
|
13991
|
-
* name: 'Root',
|
|
13992
|
-
* children: [
|
|
13993
|
-
* { name: 'A', value: 30 },
|
|
13994
|
-
* { name: 'B', value: 70 }
|
|
13995
|
-
* ]
|
|
13996
|
-
* }]
|
|
13997
|
-
* });
|
|
13998
|
-
*/
|
|
13999
|
-
class jmSunburstSeries extends jmSeries {
|
|
14000
|
-
constructor(options) {
|
|
14001
|
-
options.style = options.style || options.graph.style.sunburst;
|
|
14002
|
-
super(options);
|
|
14003
|
-
this.maxDepth = 0;
|
|
14004
|
-
}
|
|
14005
|
-
|
|
14006
|
-
/**
|
|
14007
|
-
* 初始化旭日图
|
|
14008
|
-
*/
|
|
14009
|
-
init() {
|
|
14010
|
-
const data = this.option.data || this.data;
|
|
14011
|
-
if (!data || !data.length) return;
|
|
14012
|
-
const chartWidth = this.graph.chartArea.width;
|
|
14013
|
-
const chartHeight = this.graph.chartArea.height;
|
|
14014
|
-
const centerX = chartWidth / 2;
|
|
14015
|
-
const centerY = chartHeight / 2;
|
|
14016
|
-
const maxRadius = Math.min(chartWidth, chartHeight) / 2 - 20;
|
|
14017
|
-
this.maxDepth = this.calculateMaxDepth(data);
|
|
14018
|
-
if (this.maxDepth === 0) return;
|
|
14019
|
-
const ringWidth = maxRadius / this.maxDepth;
|
|
14020
|
-
const innerRadius = this.style.innerRadius || 0;
|
|
14021
|
-
this.drawLevel(data, centerX, centerY, innerRadius, ringWidth, 0, 360, 0);
|
|
14022
|
-
if (this.style.showCenter !== false && innerRadius > 0) {
|
|
14023
|
-
this.drawCenter(centerX, centerY, innerRadius);
|
|
14024
|
-
}
|
|
14025
|
-
}
|
|
14026
|
-
|
|
14027
|
-
/**
|
|
14028
|
-
* 计算最大深度
|
|
14029
|
-
*/
|
|
14030
|
-
calculateMaxDepth(data, depth = 1) {
|
|
14031
|
-
let maxDepth = depth;
|
|
14032
|
-
for (const node of data) {
|
|
14033
|
-
if (node.children && node.children.length > 0) {
|
|
14034
|
-
const childDepth = this.calculateMaxDepth(node.children, depth + 1);
|
|
14035
|
-
maxDepth = Math.max(maxDepth, childDepth);
|
|
14036
|
-
}
|
|
14037
|
-
}
|
|
14038
|
-
return maxDepth;
|
|
14039
|
-
}
|
|
14040
|
-
|
|
14041
|
-
/**
|
|
14042
|
-
* 计算节点总值
|
|
14043
|
-
*/
|
|
14044
|
-
calculateTotalValue(data) {
|
|
14045
|
-
let total = 0;
|
|
14046
|
-
for (const node of data) {
|
|
14047
|
-
if (node.children && node.children.length > 0) {
|
|
14048
|
-
total += this.calculateTotalValue(node.children);
|
|
14049
|
-
} else {
|
|
14050
|
-
total += node.value || 0;
|
|
14051
|
-
}
|
|
14052
|
-
}
|
|
14053
|
-
return total;
|
|
14054
|
-
}
|
|
14055
|
-
|
|
14056
|
-
/**
|
|
14057
|
-
* 绘制层级
|
|
14058
|
-
*/
|
|
14059
|
-
drawLevel(data, centerX, centerY, innerRadius, ringWidth, startAngle, totalAngle, level) {
|
|
14060
|
-
const total = this.calculateTotalValue(data);
|
|
14061
|
-
if (total === 0) return;
|
|
14062
|
-
let currentAngle = startAngle;
|
|
14063
|
-
const outerRadius = innerRadius + ringWidth;
|
|
14064
|
-
for (const node of data) {
|
|
14065
|
-
let nodeValue = 0;
|
|
14066
|
-
if (node.children && node.children.length > 0) {
|
|
14067
|
-
nodeValue = this.calculateTotalValue(node.children);
|
|
14068
|
-
} else {
|
|
14069
|
-
nodeValue = node.value || 0;
|
|
14070
|
-
}
|
|
14071
|
-
const angleRatio = nodeValue / total;
|
|
14072
|
-
const nodeAngle = totalAngle * angleRatio;
|
|
14073
|
-
const endAngle = currentAngle + nodeAngle;
|
|
14074
|
-
if (nodeAngle > 0.1) {
|
|
14075
|
-
const color = this.getColor(node, level);
|
|
14076
|
-
this.drawArc(centerX, centerY, innerRadius, outerRadius, currentAngle, endAngle, color, node);
|
|
14077
|
-
if (this.style.showLabels !== false && nodeAngle > 10) {
|
|
14078
|
-
this.drawLabel(centerX, centerY, innerRadius, outerRadius, currentAngle, endAngle, node);
|
|
14079
|
-
}
|
|
14080
|
-
if (node.children && node.children.length > 0) {
|
|
14081
|
-
this.drawLevel(node.children, centerX, centerY, outerRadius, ringWidth, currentAngle, nodeAngle, level + 1);
|
|
14082
|
-
}
|
|
14083
|
-
}
|
|
14084
|
-
currentAngle = endAngle;
|
|
14085
|
-
}
|
|
14086
|
-
}
|
|
14087
|
-
|
|
14088
|
-
/**
|
|
14089
|
-
* 绘制扇形
|
|
14090
|
-
*/
|
|
14091
|
-
drawArc(centerX, centerY, innerRadius, outerRadius, startAngle, endAngle, color, node) {
|
|
14092
|
-
const arc = this.graph.createShape('arc', {
|
|
14093
|
-
style: {
|
|
14094
|
-
fill: color,
|
|
14095
|
-
stroke: this.style.stroke || '#fff',
|
|
14096
|
-
lineWidth: this.style.lineWidth || 1,
|
|
14097
|
-
zIndex: 1
|
|
14098
|
-
},
|
|
14099
|
-
center: {
|
|
14100
|
-
x: centerX,
|
|
14101
|
-
y: centerY
|
|
14102
|
-
},
|
|
14103
|
-
radius: outerRadius,
|
|
14104
|
-
innerRadius: innerRadius,
|
|
14105
|
-
startAngle: startAngle - 90,
|
|
14106
|
-
endAngle: endAngle - 90
|
|
14107
|
-
});
|
|
14108
|
-
this.addShape(arc);
|
|
14109
|
-
node.shape = arc;
|
|
14110
|
-
}
|
|
14111
|
-
|
|
14112
|
-
/**
|
|
14113
|
-
* 绘制标签
|
|
14114
|
-
*/
|
|
14115
|
-
drawLabel(centerX, centerY, innerRadius, outerRadius, startAngle, endAngle, node) {
|
|
14116
|
-
const midAngle = (startAngle + endAngle) / 2 - 90;
|
|
14117
|
-
const midRadius = (innerRadius + outerRadius) / 2;
|
|
14118
|
-
const x = centerX + midRadius * Math.cos(midAngle * Math.PI / 180);
|
|
14119
|
-
const y = centerY + midRadius * Math.sin(midAngle * Math.PI / 180);
|
|
14120
|
-
const text = node.name || '';
|
|
14121
|
-
if (!text) return;
|
|
14122
|
-
const label = this.graph.createShape('label', {
|
|
14123
|
-
style: {
|
|
14124
|
-
fill: this.style.labelColor || '#fff',
|
|
14125
|
-
font: this.style.labelFont || '12px Arial',
|
|
14126
|
-
textAlign: 'center',
|
|
14127
|
-
textBaseline: 'middle',
|
|
14128
|
-
zIndex: 10
|
|
14129
|
-
},
|
|
14130
|
-
text: text,
|
|
14131
|
-
position: {
|
|
14132
|
-
x,
|
|
14133
|
-
y
|
|
14134
|
-
}
|
|
14135
|
-
});
|
|
14136
|
-
this.addShape(label);
|
|
14137
|
-
}
|
|
14138
|
-
|
|
14139
|
-
/**
|
|
14140
|
-
* 绘制中心
|
|
14141
|
-
*/
|
|
14142
|
-
drawCenter(centerX, centerY, innerRadius) {
|
|
14143
|
-
const centerCircle = this.graph.createShape('circle', {
|
|
14144
|
-
style: {
|
|
14145
|
-
fill: this.style.centerFill || '#fff',
|
|
14146
|
-
stroke: this.style.centerStroke || '#e0e0e0',
|
|
14147
|
-
lineWidth: 1,
|
|
14148
|
-
zIndex: 0
|
|
14149
|
-
},
|
|
14150
|
-
center: {
|
|
14151
|
-
x: centerX,
|
|
14152
|
-
y: centerY
|
|
14153
|
-
},
|
|
14154
|
-
radius: innerRadius
|
|
14155
|
-
});
|
|
14156
|
-
this.addShape(centerCircle);
|
|
14157
|
-
}
|
|
14158
|
-
|
|
14159
|
-
/**
|
|
14160
|
-
* 获取颜色
|
|
14161
|
-
*/
|
|
14162
|
-
getColor(node, level) {
|
|
14163
|
-
if (node.color) return node.color;
|
|
14164
|
-
if (this.style.colors && this.style.colors.length > 0) {
|
|
14165
|
-
return this.style.colors[level % this.style.colors.length];
|
|
14166
|
-
}
|
|
14167
|
-
if (typeof this.style.color === 'function') {
|
|
14168
|
-
return this.style.color.call(this, node, level);
|
|
14169
|
-
}
|
|
14170
|
-
return this.graph.getColor(level);
|
|
14171
|
-
}
|
|
14172
|
-
|
|
14173
|
-
/**
|
|
14174
|
-
* 生成图例
|
|
14175
|
-
*/
|
|
14176
|
-
createLegend() {
|
|
14177
|
-
const style = this.graph.utils.clone(this.style);
|
|
14178
|
-
style.fill = this.style.color || this.graph.getColor(0);
|
|
14179
|
-
style.stroke = style.fill;
|
|
14180
|
-
const shape = this.graph.createShape('circle', {
|
|
14181
|
-
style: style,
|
|
14182
|
-
center: {
|
|
14183
|
-
x: this.graph.style.legend.item.shape.width / 2,
|
|
14184
|
-
y: this.graph.style.legend.item.shape.height / 2
|
|
14185
|
-
},
|
|
14186
|
-
radius: this.graph.style.legend.item.shape.height / 2
|
|
14187
|
-
});
|
|
14188
|
-
this.graph.legend.append(this, shape);
|
|
14189
|
-
}
|
|
14190
|
-
}
|
|
14191
|
-
|
|
14192
14057
|
/**
|
|
14193
14058
|
* 轴
|
|
14194
14059
|
*
|
|
@@ -14908,8 +14773,7 @@ var jmChart = (function (exports) {
|
|
|
14908
14773
|
'funnel': jmFunnelSeries,
|
|
14909
14774
|
'ringProgress': jmRingProgressSeries,
|
|
14910
14775
|
'boxPlot': jmBoxPlotSeries,
|
|
14911
|
-
'wordCloud': jmWordCloudSeries
|
|
14912
|
-
'sunburst': jmSunburstSeries
|
|
14776
|
+
'wordCloud': jmWordCloudSeries
|
|
14913
14777
|
};
|
|
14914
14778
|
}
|
|
14915
14779
|
|