提交 d2ae099b 编写于 作者: P pissang

Optimize indices creation.

上级 145ad212
...@@ -148,8 +148,8 @@ export default echarts.extendChartView({ ...@@ -148,8 +148,8 @@ export default echarts.extendChartView({
); );
polyline.hoverStyle = itemModel.getModel('emphasis.lineStyle').getLineStyle(); polyline.hoverStyle = itemModel.getModel('emphasis.lineStyle').getLineStyle();
var areaStyleModel = itemModel.getModel('areaStyle.normal'); var areaStyleModel = itemModel.getModel('areaStyle');
var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis'); var hoverAreaStyleModel = itemModel.getModel('areaStyle');
var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty(); var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty(); var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty();
......
...@@ -25,7 +25,12 @@ var dataCtors = { ...@@ -25,7 +25,12 @@ var dataCtors = {
'time': Array 'time': Array
}; };
var CtorUint32Array = typeof globalObj.Uint32Array === UNDEFINED ? Array : globalObj.Uint32Array; function getIndicesCtor(count) {
var CtorUint32Array = typeof globalObj.Uint32Array === UNDEFINED ? Array : globalObj.Uint32Array;
var CtorUint16Array = typeof globalObj.Uint16Array === UNDEFINED ? Array : globalObj.Uint16Array;
return count > 65535 ? CtorUint32Array : CtorUint16Array;
}
function cloneChunk(originalChunk) { function cloneChunk(originalChunk) {
var Ctor = originalChunk.constructor; var Ctor = originalChunk.constructor;
...@@ -547,14 +552,17 @@ listProto._initDataFromProvider = function (start, end) { ...@@ -547,14 +552,17 @@ listProto._initDataFromProvider = function (start, end) {
* @return {number} * @return {number}
*/ */
listProto.count = function () { listProto.count = function () {
return this._indices ? this._indices.length : this._count; return this._count;
}; };
listProto.getIndices = function () { listProto.getIndices = function () {
if (this._indices) { if (this._indices) {
return this._indices; var Ctor = this._indices.constructor;
return new Ctor(this._indices.buffer, 0, this._count);
} }
var arr = new CtorUint32Array(this.count());
var Ctor = getIndicesCtor(this.count());
var arr = new Ctor(this.count());
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
arr[i] = arr; arr[i] = arr;
} }
...@@ -1003,12 +1011,14 @@ listProto.filterSelf = function (dimensions, cb, stack, context) { ...@@ -1003,12 +1011,14 @@ listProto.filterSelf = function (dimensions, cb, stack, context) {
normalizeDimensions(dimensions), this.getDimension, this normalizeDimensions(dimensions), this.getDimension, this
); );
var newIndices = []; var Ctor = getIndicesCtor(this.count());
var newIndices = new Ctor(this.count());
var value = []; var value = [];
var dimSize = dimensions.length; var dimSize = dimensions.length;
context = context || this; context = context || this;
var offset = 0;
for (var i = 0; i < this.count(); i++) { for (var i = 0; i < this.count(); i++) {
var keep; var keep;
// Simple optimization // Simple optimization
...@@ -1028,12 +1038,13 @@ listProto.filterSelf = function (dimensions, cb, stack, context) { ...@@ -1028,12 +1038,13 @@ listProto.filterSelf = function (dimensions, cb, stack, context) {
keep = cb.apply(context, value); keep = cb.apply(context, value);
} }
if (keep) { if (keep) {
newIndices.push(this.getRawIndex(i)); newIndices[offset++] = this.getRawIndex(i);
} }
} }
this._indices = new Uint32Array(newIndices); // Set indices after filtered.
this._indices = newIndices;
this._count = offset;
// Reset data extent // Reset data extent
this._extent = {}; this._extent = {};
...@@ -1427,7 +1438,8 @@ listProto.cloneShallow = function (list) { ...@@ -1427,7 +1438,8 @@ listProto.cloneShallow = function (list) {
// Clone will not change the data extent and indices // Clone will not change the data extent and indices
if (this._indices) { if (this._indices) {
list._indices = new CtorUint32Array(this._indices); var Ctor = this._indices.constructor;
list._indices = new Ctor(this._indices);
} }
else { else {
list._indices = null; list._indices = null;
......
...@@ -44,7 +44,7 @@ chart.setOption({ ...@@ -44,7 +44,7 @@ chart.setOption({
type: 'scatter', type: 'scatter',
progressive: 1e5, progressive: 1e5,
coordinateSystem: 'geo', coordinateSystem: 'geo',
symbolSize: 1, symbolSize: 0.5,
blendMode: 'lighter', blendMode: 'lighter',
large: true, large: true,
itemStyle: { itemStyle: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册