* @private
*/
_parseObjectData: function(meta, data, start, count) {
- const iScale = meta.iScale;
- const vScale = meta.vScale;
+ const {iScale, vScale} = meta;
const vProp = vScale.axis;
const parsed = [];
let i, ilen, item, obj, value;
_getLabelAndValue: function(index) {
const me = this;
const meta = me._cachedMeta;
- const indexScale = meta.iScale;
- const valueScale = meta.vScale;
+ const {iScale, vScale} = meta;
const parsed = me._getParsed(index);
const custom = parsed._custom;
const value = custom
? '[' + custom.start + ', ' + custom.end + ']'
- : '' + valueScale.getLabelForValue(parsed[valueScale.id]);
+ : '' + vScale.getLabelForValue(parsed[vScale.id]);
return {
- label: '' + indexScale.getLabelForValue(parsed[indexScale.id]),
+ label: '' + iScale.getLabelForValue(parsed[iScale.id]),
value: value
};
},
* @private
*/
_parseObjectData: function(meta, data, start, count) {
- const xScale = meta.xScale;
- const yScale = meta.yScale;
+ const {xScale, yScale} = meta;
+ const xId = xScale.id;
+ const yId = yScale.id;
const parsed = [];
- var i, ilen, item, obj;
+ let i, ilen, item;
for (i = start, ilen = start + count; i < ilen; ++i) {
- obj = data[i];
- item = {};
- item[xScale.id] = xScale._parseObject(obj, 'x', i);
- item[yScale.id] = yScale._parseObject(obj, 'y', i);
- item._custom = obj && obj.r && +obj.r;
- parsed.push(item);
+ item = data[i];
+ parsed.push({
+ [xId]: xScale._parseObject(item, 'x', i),
+ [yId]: yScale._parseObject(item, 'y', i),
+ _custom: item && item.r && +item.r
+ });
}
return parsed;
},
_getLabelAndValue: function(index) {
const me = this;
const meta = me._cachedMeta;
- const xScale = meta.xScale;
- const yScale = meta.yScale;
+ const {xScale, yScale} = meta;
const parsed = me._getParsed(index);
const x = xScale.getLabelForValue(parsed[xScale.id]);
const y = yScale.getLabelForValue(parsed[yScale.id]);
*/
updateElements: function(points, start, count, reset) {
const me = this;
- const meta = me._cachedMeta;
- const xScale = meta.xScale;
- const yScale = meta.yScale;
+ const {xScale, yScale} = me._cachedMeta;
let i;
for (i = start; i < start + count; i++) {
}
function updateStacks(controller, parsed) {
- const chart = controller.chart;
- const meta = controller._cachedMeta;
+ const {chart, _cachedMeta: meta} = controller;
const stacks = chart._stacks || (chart._stacks = {}); // map structure is {stackKey: {datasetIndex: value}}
- const xScale = meta.xScale;
- const yScale = meta.yScale;
- const xId = xScale.id;
- const yId = yScale.id;
- const xStacked = isStacked(xScale, meta);
- const yStacked = isStacked(yScale, meta);
- const xKey = yStacked && getStackKey(xScale, yScale, meta);
- const yKey = xStacked && getStackKey(yScale, xScale, meta);
+ const {iScale, vScale, index: datasetIndex} = meta;
+ const iId = iScale.id;
+ const vId = vScale.id;
+ const key = getStackKey(iScale, vScale, meta);
const ilen = parsed.length;
- const datasetIndex = meta.index;
let stack;
for (let i = 0; i < ilen; ++i) {
const item = parsed[i];
- const x = item[xId];
- const y = item[yId];
+ const {[iId]: index, [vId]: value} = item;
const itemStacks = item._stacks || (item._stacks = {});
-
- if (yStacked) {
- stack = itemStacks[yId] = getOrCreateStack(stacks, xKey, x);
- stack[datasetIndex] = y;
- }
- if (xStacked) {
- stack = itemStacks[xId] = getOrCreateStack(stacks, yKey, y);
- stack[datasetIndex] = x;
- }
+ stack = itemStacks[vId] = getOrCreateStack(stacks, key, index);
+ stack[datasetIndex] = value;
}
}
*/
_parse: function(start, count) {
const me = this;
- const meta = me._cachedMeta;
- const data = me._data;
- const iScale = meta.iScale;
- const vScale = meta.vScale;
- const stacked = isStacked(iScale, meta) || isStacked(vScale, meta);
+ const {_cachedMeta: meta, _data: data} = me;
+ const {iScale, vScale, _stacked} = meta;
let i, ilen, parsed;
if (helpers.isArray(data[start])) {
for (i = 0, ilen = parsed.length; i < ilen; ++i) {
meta.data[start + i]._parsed = parsed[i];
}
- if (stacked) {
+
+ if (_stacked) {
updateStacks(me, parsed);
}
* @private
*/
_parsePrimitiveData: function(meta, data, start, count) {
- const iScale = meta.iScale;
- const vScale = meta.vScale;
+ const {iScale, vScale} = meta;
+ const iId = iScale.id;
+ const vId = vScale.id;
const labels = iScale._getLabels();
const singleScale = iScale === vScale;
const parsed = [];
for (i = start, ilen = start + count; i < ilen; ++i) {
item = {};
- item[iScale.id] = singleScale || iScale._parse(labels[i], i);
- item[vScale.id] = vScale._parse(data[i], i);
+ item[iId] = singleScale || iScale._parse(labels[i], i);
+ item[vId] = vScale._parse(data[i], i);
parsed.push(item);
}
return parsed;
* @private
*/
_parseArrayData: function(meta, data, start, count) {
- const xScale = meta.xScale;
- const yScale = meta.yScale;
+ const {xScale, yScale} = meta;
+ const xId = xScale.id;
+ const yId = yScale.id;
const parsed = [];
- let i, ilen, item, arr;
+ let i, ilen, item;
for (i = start, ilen = start + count; i < ilen; ++i) {
- arr = data[i];
- item = {};
- item[xScale.id] = xScale._parse(arr[0], i);
- item[yScale.id] = yScale._parse(arr[1], i);
- parsed.push(item);
+ item = data[i];
+ parsed.push({
+ [xId]: xScale._parse(item[0], i),
+ [yId]: yScale._parse(item[1], i)
+ });
}
return parsed;
},
* @private
*/
_parseObjectData: function(meta, data, start, count) {
- const xScale = meta.xScale;
- const yScale = meta.yScale;
+ const {xScale, yScale} = meta;
+ const xId = xScale.id;
+ const yId = yScale.id;
const parsed = [];
- let i, ilen, item, obj;
+ let i, ilen, item;
for (i = start, ilen = start + count; i < ilen; ++i) {
- obj = data[i];
- item = {};
- item[xScale.id] = xScale._parseObject(obj, 'x', i);
- item[yScale.id] = yScale._parseObject(obj, 'y', i);
- parsed.push(item);
+ item = data[i];
+ parsed.push({
+ [xId]: xScale._parseObject(item, 'x', i),
+ [yId]: yScale._parseObject(item, 'y', i)
+ });
}
return parsed;
},