Skip to content

Commit

Permalink
markLine precision
Browse files Browse the repository at this point in the history
  • Loading branch information
kener committed Jan 4, 2015
1 parent a67ba4f commit dad6284
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 15 additions & 10 deletions src/chart/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,8 @@ define(function (require) {
if (xy.indexOf('x') != '-1') {
if (xMarkMap[seriesIndex]['counter' + valueIndex] > 0) {
xMarkMap[seriesIndex]['average' + valueIndex] =
(xMarkMap[seriesIndex]['sum' + valueIndex]
/ xMarkMap[seriesIndex]['counter' + valueIndex]
).toFixed(2)
- 0;
xMarkMap[seriesIndex]['sum' + valueIndex]
/ xMarkMap[seriesIndex]['counter' + valueIndex];
}

var x = this.component.xAxis.getAxis(series[seriesIndex].xAxisIndex || 0)
Expand Down Expand Up @@ -485,10 +483,8 @@ define(function (require) {
if (xy.indexOf('y') != '-1') {
if (xMarkMap[seriesIndex]['counter' + valueIndex] > 0) {
xMarkMap[seriesIndex]['average' + valueIndex] =
(xMarkMap[seriesIndex]['sum' + valueIndex]
/ xMarkMap[seriesIndex]['counter' + valueIndex]
).toFixed(2)
- 0;
xMarkMap[seriesIndex]['sum' + valueIndex]
/ xMarkMap[seriesIndex]['counter' + valueIndex];
}
var y = this.component.yAxis.getAxis(series[seriesIndex].yAxisIndex || 0)
.getCoord(xMarkMap[seriesIndex]['average' + valueIndex]);
Expand Down Expand Up @@ -545,6 +541,8 @@ define(function (require) {
: nLabel.position;
tarShape.style.textColor = nTextStyle.color;
tarShape.style.textFont = this.getFont(nTextStyle);
tarShape.style.textAlign = nTextStyle.align;
tarShape.style.textBaseline = nTextStyle.baseline;
}
if (eLabel.show) {
tarShape.highlightStyle.text = this._getLabelText(
Expand All @@ -557,6 +555,8 @@ define(function (require) {
: eLabel.position);
tarShape.highlightStyle.textColor = eTextStyle.color;
tarShape.highlightStyle.textFont = this.getFont(eTextStyle);
tarShape.highlightStyle.textAlign = eTextStyle.align;
tarShape.highlightStyle.textBaseline = eTextStyle.baseline;
}

return tarShape;
Expand Down Expand Up @@ -611,8 +611,8 @@ define(function (require) {
buildMark: function (seriesIndex) {
var serie = this.series[seriesIndex];
if (this.selectedMap[serie.name]) {
serie.markLine && this._buildMarkLine(seriesIndex);
serie.markPoint && this._buildMarkPoint(seriesIndex);
serie.markLine && this._buildMarkLine(seriesIndex);
}
},

Expand Down Expand Up @@ -679,7 +679,12 @@ define(function (require) {
pos = this.getMarkCoord(seriesIndex, mlData);
markLine.data[i] = [zrUtil.clone(mlData), {}];
markLine.data[i][0].name = mlData.name || mlData.type;
markLine.data[i][0].value = pos[3];
markLine.data[i][0].value = mlData.type !== 'average'
? pos[3]
: pos[3].toFixed(
markLine.precision != null
? markLine.precision : this.ecTheme.markLine.precision
) - 0;
pos = pos[2];
mlData = [{},{}];
}
Expand Down
4 changes: 2 additions & 2 deletions src/chart/scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ define(function (require) {
var gridY = this.component.grid.getY();
var gridYend = this.component.grid.getYend();

xMarkMap.average0 = (xMarkMap.sum0 / xMarkMap.counter0).toFixed(2) - 0;
xMarkMap.average0 = xMarkMap.sum0 / xMarkMap.counter0;
var x = xAxis.getCoord(xMarkMap.average0);
// 横轴平均纵向
xMarkMap.averageLine0 = [
Expand All @@ -244,7 +244,7 @@ define(function (require) {
[xMarkMap.maxX0, gridY]
];

xMarkMap.average1 = (xMarkMap.sum1 / xMarkMap.counter1).toFixed(2) - 0;
xMarkMap.average1 = xMarkMap.sum1 / xMarkMap.counter1;
var y = yAxis.getCoord(xMarkMap.average1);
// 纵轴平均横向
xMarkMap.averageLine1 = [
Expand Down

0 comments on commit dad6284

Please sign in to comment.