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