Skip to content

Commit

Permalink
Chord : add style configs
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Nov 4, 2013
1 parent 260a069 commit 2a4e81d
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 18 deletions.
22 changes: 17 additions & 5 deletions doc/example/chord.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@
itemStyle : {
normal : {
lineStyle : {
width: 1,
color: '#ccc',
width : 0,
color : '#000'
},
chordStyle : {
lineStyle : {
width : 1,
color : '#333'
}
},
label: {
show: true,
Expand All @@ -103,8 +109,14 @@
},
emphasis : {
lineStyle : {
width: 2,
color: '#fff',
width : 0,
color : '#000'
},
chordStyle : {
lineStyle : {
width : 2,
color : 'black'
}
}
}
},
Expand All @@ -113,7 +125,7 @@
name : 'g1',
itemStyle : {
normal: {
color: 'rgba(250,10,10,0.5)',
color: 'rgb(200,100,100)',
lineStyle : {
width: 1,
color: 'green',
Expand Down
87 changes: 75 additions & 12 deletions src/chart/chord.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ define(function(require) {

var _zlevelBase = self.getZlevelBase();

var chordSerieSample;
// Config
var chordSeries = [];
var groups;
Expand All @@ -51,8 +52,6 @@ define(function(require) {
var center;
var showScale;
var showScaleText;
var showLabel;
var labelColor;

var strokeFix = 0;
// Adjacency matrix
Expand All @@ -68,7 +67,7 @@ define(function(require) {

self.selectedMap = {};
chordSeries = [];
var chordSerieSample;
chordSerieSample = null;
var matrix = [];
var serieNumber = 0;
for (var i = 0, l = series.length; i < l; i++) {
Expand Down Expand Up @@ -127,13 +126,9 @@ define(function(require) {
self.parsePercent(chordSerieSample.center[0], zrWidth),
self.parsePercent(chordSerieSample.center[1], zrHeight),
];
showLabel = self.deepQuery(
[chordSerieSample], 'itemStyle.normal.label.show'
);
labelColor = self.deepQuery(
[chordSerieSample], 'itemStyle.normal.label.color'
);
// Supporse the line width is 1;
var fixSize =
chordSerieSample.itemStyle.normal.chordStyle.lineStyle.width -
chordSerieSample.itemStyle.normal.lineStyle.width;
strokeFix = (1 / _devicePixelRatio) / innerRadius / Math.PI * 180;


Expand Down Expand Up @@ -304,6 +299,14 @@ define(function(require) {
var len2 = chordSeries.length;

var timeout;

var showLabel = self.deepQuery(
[chordSerieSample], 'itemStyle.normal.label.show'
);
var labelColor = self.deepQuery(
[chordSerieSample], 'itemStyle.normal.label.color'
);

function createMouseOver(idx) {
return function() {
if (timeout) {
Expand Down Expand Up @@ -381,12 +384,35 @@ define(function(require) {
startAngle : _start,
endAngle : _end,
brushType : 'fill',
opacity: 1,
color : legend.getColor(group.name)
},
highlightStyle : {
brushType : 'fill'
}
};
sector.style.lineWidth = self.deepQuery(
[group, chordSerieSample],
'itemStyle.normal.lineStyle.width'
);
sector.highlightStyle.lineWidth = self.deepQuery(
[group, chordSerieSample],
'itemStyle.emphasis.lineStyle.width'
);
sector.style.strokeColor = self.deepQuery(
[group, chordSerieSample],
'itemStyle.normal.lineStyle.color'
);
sector.highlightStyle.strokeColor = self.deepQuery(
[group, chordSerieSample],
'itemStyle.emphasis.lineStyle.color'
);
if (sector.style.lineWidth > 0) {
sector.style.brushType = 'both';
}
if (sector.highlightStyle.lineWidth > 0) {
sector.highlightStyle.brushType = 'both';
}
ecData.pack(
sector,
chordSeries[0],
Expand Down Expand Up @@ -420,6 +446,14 @@ define(function(require) {
hoverable : false
}
};
labelShape.style.textColor = self.deepQuery(
[group, chordSerieSample],
'itemStyle.normal.label.textStyle.color'
) || '#fff';
sector.style.textFont = self.getFont(self.deepQuery(
[group, chordSerieSample],
'itemStyle.normal.label.textStyle'
));
zr.addShape(labelShape);
self.shapeList.push(labelShape)
}
Expand All @@ -440,6 +474,11 @@ define(function(require) {
}
var len2 = angles[0][0].length;

var chordLineStyle
= chordSerieSample.itemStyle.normal.chordStyle.lineStyle;
var chordLineStyleEmphsis
= chordSerieSample.itemStyle.emphasis.chordStyle.lineStyle;

for (var i = 0; i < len; i++) {
for (var j = 0; j < len; j++) {
for (var k = 0; k < len2; k++) {
Expand Down Expand Up @@ -485,10 +524,14 @@ define(function(require) {
brushType : 'both',
strokeColor : 'black',
opacity : 0.5,
color : color
color : color,
lineWidth : chordLineStyle.width,
strokeColor : chordLineStyle.color
},
highlightStyle : {
brushType : 'fill'
brushType : 'both',
lineWidth : chordLineStyleEmphsis.width,
strokeColor : chordLineStyleEmphsis.color
}
};

Expand Down Expand Up @@ -636,6 +679,26 @@ define(function(require) {
zr.refresh();
}

function reformOption(opt) {
var _merge = zrUtil.merge;
opt = _merge(
opt || {},
ecConfig.pie,
{
'overwrite' : false,
'recursive' : true
}
);
opt.itemStyle.normal.label.textStyle = _merge(
opt.itemStyle.normal.label.textStyle || {},
ecConfig.textStyle,
{
'overwrite' : false,
'recursive' : true
}
);
}

self.init = init;
self.refresh = refresh;

Expand Down
24 changes: 23 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,29 @@ define(function() {
normal : {
label : {
show : true,
color : 'black'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
lineStyle : {
width : 0,
color : '#000'
},
chordStyle : {
lineStyle : {
width : 1,
color : 'black'
}
}
},
emphasis : {
lineStyle : {
width : 0,
color : '#000'
},
chordStyle : {
lineStyle : {
width : 2,
color : 'black'
}
}
}
},
Expand Down

0 comments on commit 2a4e81d

Please sign in to comment.