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