Skip to content

Commit f28626c

Browse files
committed
chod 多个serie合并 bugfix
1 parent 4c25d26 commit f28626c

File tree

1 file changed

+27
-40
lines changed

1 file changed

+27
-40
lines changed

src/chart/chord.js

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ define(function (require) {
181181
this._buildLabels(mainSerie, 0, mainGraph, mainSerie, graphs);
182182
}
183183

184-
for (var i = 0; i < graphs.length; i++) {
185-
this._buildRibbons(series[i], i, graphs[i], mainSerie);
184+
for (var i = 0, j = 0; i < series.length; i++) {
185+
if (this.selectedMap[series[i].name]) {
186+
this._buildRibbons(series, i, graphs[j++], mainSerie);
187+
}
186188
}
187189

188190
if (serie.showScale) {
@@ -194,8 +196,10 @@ define(function (require) {
194196
if (showLabel) {
195197
this._buildLabels(mainSerie, 0, mainGraph, mainSerie, graphs);
196198
}
197-
for (var i = 0; i < graphs.length; i++) {
198-
this._buildEdgeCurves(series[i], i, graphs[i], mainSerie);
199+
for (var i = 0, j = 0; i < series.length; i++) {
200+
if (this.selectedMap[series[i].name]) {
201+
this._buildEdgeCurves(series, i, graphs[j++], mainSerie);
202+
}
199203
}
200204
}
201205

@@ -391,7 +395,7 @@ define(function (require) {
391395
});
392396
},
393397

394-
_buildSectors: function (serie, serieIdx, graph, mainSerie, graphs) {
398+
_buildSectors: function (serie, serieIdx, graph, mainSerie) {
395399
var timeout;
396400

397401
var self = this;
@@ -578,7 +582,9 @@ define(function (require) {
578582
}, this);
579583
},
580584

581-
_buildRibbons : function (serie, serieIdx, graph, mainSerie) {
585+
_buildRibbons : function (series, serieIdx, graph, mainSerie) {
586+
var serie = series[serieIdx];
587+
582588
var ribbonStyle
583589
= mainSerie.itemStyle.normal.chordStyle;
584590
var ribbonStyleEmphsis
@@ -607,12 +613,17 @@ define(function (require) {
607613
var t0 = other.layout.startAngle / Math.PI * 180;
608614
var t1 = other.layout.endAngle / Math.PI * 180;
609615

610-
// 取小端的颜色
611-
if (edge.layout.weight <= other.layout.weight) {
612-
color = this.getColor(edge.node1.id);
613-
}
614-
else {
615-
color = this.getColor(edge.node2.id);
616+
if (series.length === 1) {
617+
// 取小端的颜色
618+
if (edge.layout.weight <= other.layout.weight) {
619+
color = this.getColor(edge.node1.id);
620+
}
621+
else {
622+
color = this.getColor(edge.node2.id);
623+
}
624+
} else {
625+
// 使用系列颜色
626+
color = this.getColor(serie.name);
616627
}
617628
var queryTarget = [edge.data, mainSerie];
618629
var ribbon = new RibbonShape({
@@ -659,7 +670,9 @@ define(function (require) {
659670
}, this);
660671
},
661672

662-
_buildEdgeCurves: function (serie, serieIdx, graph, mainSerie) {
673+
_buildEdgeCurves: function (series, serieIdx, graph, mainSerie) {
674+
var serie = series[serieIdx];
675+
663676
var center = this.parseCenter(this.zr, mainSerie.center);
664677
var radius = this.parseRadius(this.zr, mainSerie.radius);
665678

@@ -841,34 +854,8 @@ define(function (require) {
841854
if (colorMap[key]) {
842855
return colorMap[key];
843856
}
844-
if (colorIndices[key] === undefined) {
845-
colorIndices[key] = count++;
846-
}
847-
// key is serie name
848-
for (var i = 0; i < this.chordSeries.length; i++) {
849-
if (this.chordSeries[i].name === key) {
850-
colorMap[key] = this.query(
851-
this.chordSeries[i],
852-
'itemStyle.normal.color'
853-
);
854-
break;
855-
}
856-
}
857-
if (!colorMap[key]) {
858-
var len = this.groups.length;
859-
// key is group name
860-
for (var i = 0; i < len; i++) {
861-
if (this.groups[i].name === key) {
862-
colorMap[key] = this.query(
863-
this.groups[i],
864-
'itemStyle.normal.color'
865-
);
866-
break;
867-
}
868-
}
869-
}
870857
if (!colorMap[key]) {
871-
colorMap[key] = this.zr.getColor(colorIndices[key]);
858+
colorMap[key] = this.zr.getColor(count++);
872859
}
873860

874861
return colorMap[key];

0 commit comments

Comments
 (0)