提交 561408af 编写于 作者: D deqingli

Merge remote-tracking branch 'origin/master' into sankey

......@@ -161,6 +161,7 @@ pip-log.txt
# Mac crap
.DS_Store
.idea
node_modules
......
......@@ -82,6 +82,7 @@ ECharts-GL is an extension pack of ECharts, which provides 3D plots, globe visua
#### Ember Binding
+ [echarts-ember](https://github.com/bruckwubete/echarts-ember) by [bruck wubete](https://github.com/bruckwubete)
+ [ember-cli-echarts](https://github.com/funnelcloudinc/ember-cli-echarts) by FunnelCloud
#### Vue Component
......
......@@ -22,11 +22,13 @@ var symbolDrawProto = SymbolDraw.prototype;
function symbolNeedsDraw(data, point, idx, opt) {
return point && !isNaN(point[0]) && !isNaN(point[1])
&& !(opt.isIgnore && opt.isIgnore(idx))
// We do not set clipShape on group, because it will
// cut part of the symbol element shape.
// We do not set clipShape on group, because it will cut part of
// the symbol element shape. We use the same clip shape here as
// the line clip.
&& !(opt.clipShape && !opt.clipShape.contain(point[0], point[1]))
&& data.getItemVisual(idx, 'symbol') !== 'none';
}
/**
* Update symbols draw by new data
* @param {module:echarts/data/List} data
......
......@@ -9,6 +9,7 @@ import * as graphic from '../../util/graphic';
import * as modelUtil from '../../util/model';
import {Polyline, Polygon} from './poly';
import ChartView from '../../view/Chart';
import {round} from '../../util/number';
import {prepareDataCoordInfo, getStackedOnPoint} from './helper';
function isPointsSame(points1, points2) {
......@@ -81,6 +82,14 @@ function createGridClipShape(cartesian, hasAnimation, seriesModel) {
width += expandSize * 2;
}
// Avoid numberic rounding error (when the point is on the edge,
// the result may be unexpectedly by rounding error).
// See #7913 and `test/dataZoom-clip.html`.
x = round(x, 1);
y = round(y, 1);
width = round(width, 1);
height = round(height, 1);
var clipPath = new graphic.Rect({
shape: {
x: x,
......@@ -114,10 +123,10 @@ function createPolarClipShape(polar, hasAnimation, seriesModel) {
var clipPath = new graphic.Sector({
shape: {
cx: polar.cx,
cy: polar.cy,
r0: radiusExtent[0],
r: radiusExtent[1],
cx: round(polar.cx, 1),
cy: round(polar.cy, 1),
r0: round(radiusExtent[0], 1),
r: round(radiusExtent[1], 1),
startAngle: -angleExtent[0] * RADIAN,
endAngle: -angleExtent[1] * RADIAN,
clockwise: angleAxis.inverse
......
......@@ -171,12 +171,12 @@ MarkerView.extend({
renderSeries: function (seriesModel, maModel, ecModel, api) {
var coordSys = seriesModel.coordinateSystem;
var seriesName = seriesModel.name;
var seriesId = seriesModel.id;
var seriesData = seriesModel.getData();
var areaGroupMap = this.markerGroupMap;
var polygonGroup = areaGroupMap.get(seriesName)
|| areaGroupMap.set(seriesName, {group: new graphic.Group()});
var polygonGroup = areaGroupMap.get(seriesId)
|| areaGroupMap.set(seriesId, {group: new graphic.Group()});
this.group.add(polygonGroup.group);
polygonGroup.__keep = true;
......
......@@ -7,12 +7,12 @@ import MarkerView from './MarkerView';
var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
var data = seriesModel.getData();
// Special type markLine like 'min', 'max', 'average'
// Special type markLine like 'min', 'max', 'average', 'median'
var mlType = item.type;
if (!zrUtil.isArray(item)
&& (
mlType === 'min' || mlType === 'max' || mlType === 'average'
mlType === 'min' || mlType === 'max' || mlType === 'average' || mlType === 'median'
// In case
// data: [{
// yAxis: 10
......@@ -373,4 +373,4 @@ function createList(coordSys, seriesModel, mlModel) {
to: toData,
line: lineData
};
}
\ No newline at end of file
}
......@@ -50,7 +50,7 @@ var MarkerModel = echarts.extendComponentModel({
if (!createdBySelf) {
ecModel.eachSeries(function (seriesModel) {
var markerOpt = seriesModel.get(this.mainType);
var markerOpt = seriesModel.get(this.mainType, true);
var markerModel = seriesModel[modelPropName];
if (!markerOpt || !markerOpt.data) {
......
......@@ -212,7 +212,11 @@ export function numCalculate(data, valueDataDim, type) {
});
return sum / count;
}
else if (type === 'median') {
return data.getMedian(valueDataDim);
}
else {
// max & min
return data.getDataExtent(valueDataDim, true)[type === 'max' ? 1 : 0];
}
}
......@@ -861,6 +861,29 @@ listProto.getSum = function (dim /*, stack */) {
return sum;
};
/**
* Get median of data in one dimension
* @param {string} dim
*/
listProto.getMedian = function (dim /*, stack */) {
var dimDataArray = [];
// map all data of one dimension
this.each(dim, function (val, idx) {
if (!isNaN(val)) {
dimDataArray.push(val);
}
});
// immutability & sort
var sortedDimDataArray = [].concat(dimDataArray).sort(function(a, b) {
return a - b;
});
var len = this.count();
// calculate median
return len === 0 ? 0 :
len % 2 === 1 ? sortedDimDataArray[(len - 1) / 2] :
(sortedDimDataArray[len / 2] + sortedDimDataArray[len / 2 - 1]) / 2;
};
// /**
// * Retreive the index with given value
// * @param {string} dim Concrete dimension.
......
......@@ -18,6 +18,7 @@
</style>
<div id="main0"></div>
<div id="main1"></div>
......@@ -94,5 +95,66 @@
</script>
<script>
option = {
tooltip: {
trigger: 'axis'
},
legend: {
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['first', 'middle', 'last']
},
yAxis: {
type: 'value'
},
series: [
{
name:'邮件营销',
type:'line',
stack: '总量',
symbolSize: 20,
data:[120, 132, 101]
},
// {
// name:'联盟广告',
// type:'line',
// stack: '总量',
// symbolSize: 20,
// data:[220, 182, 191]
// }
]
};
chart = myChart = testHelper.create(echarts, 'main1', {
title: 'The first and last symbols (on the edge) should be displayed.',
option: option
});
</script>
</body>
</html>
\ No newline at end of file
<html>
<head>
<meta charset="utf-8">
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
}
</style>
<div id="main"></div>
<script>
require([
'echarts'
// 'echarts/chart/scatter',
// 'echarts/component/legend',
// 'echarts/component/grid',
// 'echarts/component/tooltip',
// 'echarts/component/toolbox'
], function (echarts) {
var chart = echarts.init(document.getElementById('main'));
var data1 = [];
var names = [
'diamond, red, show inside label only on hover',
];
var random = function (max) {
return (Math.random() * max).toFixed(3);
}
for (var i = 0; i < 50; i++) {
data1.push([random(5), random(5), random(2)]);
}
chart.setOption({
aria: {
show: true
},
legend: {
data: names.slice()
},
toolbox: {
left: 'left',
feature: {
dataView: {},
saveAsImage: {},
dataZoom: {}
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
}
},
xAxis: {
type: 'value',
splitLine: {
show: false
},
min: 0,
max: 15,
splitNumber: 30
},
yAxis: {
type: 'value',
splitLine: {
show: false
}
},
series: [{
name: names[0],
type: 'scatter',
label: {
emphasis: {
show: true
}
},
symbol: 'diamond',
symbolSize: function (val) {
return val[2] * 40;
},
data: data1,
markLine: {
data: [
{
name: '平均线',
type: 'average'
},
{
name: '最大值',
type: 'max'
},
{
name: '最小值',
type: 'min'
},
{
name: '中位数',
type: 'median'
}
]
}
}],
animationDelay: function (idx) {
return idx * 20;
},
animationDelayUpdate: function (idx) {
return idx * 20;
}
});
chart.on('click', function (params) {
console.log(params.data);
});
})
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册