Skip to content

Commit

Permalink
fix: support area with null data
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Mar 12, 2018
1 parent 60844c0 commit cff0425
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/f2",
"version": "3.1.1-beta.9",
"version": "3.1.1-beta.10",
"description": "A canvas library which providing 2d draw for G2.",
"keywords": [
"canvas",
Expand Down
1 change: 0 additions & 1 deletion src/geom/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Area extends Geom {
const yScale = self.getYScale();
const splitArray = ShapeUtil.splitArray(data, yScale.field);
cfg.origin = data; // path,line,area 等图的origin 是整个序列

Util.each(splitArray, function(subData, splitedIndex) {
cfg.splitedIndex = splitedIndex; // 传入分割片段索引 用于生成id
const points = subData.map(obj => {
Expand Down
11 changes: 8 additions & 3 deletions src/geom/shape/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ const ShapeUtil = {
Util.each(data, function(obj) {
yValue = obj._origin ? obj._origin[yField] : obj[yField];
if ((Util.isArray(yValue) && Util.isNil(yValue[0])) || Util.isNil(yValue)) {
arr.push(tmp);
tmp = [];
if (tmp.length) {
arr.push(tmp);
tmp = [];
}
} else {
tmp.push(obj);
}
});
arr.push(tmp);

if (tmp.length) {
arr.push(tmp);
}

return arr;
}
Expand Down
50 changes: 26 additions & 24 deletions src/plugin/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,30 +325,32 @@ class TooltipController {
const type = geom.get('type');
const records = geom.getSnapRecords(point);
Util.each(records, record => {
const { x, y, _origin, color } = record;
const tooltipItem = {
x,
y: Util.isArray(y) ? y[1] : y,
color: color || Global.defaultColor,
origin: _origin,
name: getTooltipName(geom, _origin),
value: getTooltipValue(geom, _origin),
title: getTooltipTitle(geom, _origin)
};
if (marker) {
tooltipItem.marker = Util.mix({
fill: color || Global.defaultColor
}, marker);
}
items.push(tooltipItem);

if ([ 'line', 'area', 'path' ].indexOf(type) !== -1) {
tooltipMarkerType = 'circle';
tooltipMarkerItems.push(tooltipItem);
} else if (type === 'interval' && coord.type === 'cartesian') {
tooltipMarkerType = 'rect';
tooltipItem.width = geom.getSize(record._origin);
tooltipMarkerItems.push(tooltipItem);
if (record.x && record.y) {
const { x, y, _origin, color } = record;
const tooltipItem = {
x,
y: Util.isArray(y) ? y[1] : y,
color: color || Global.defaultColor,
origin: _origin,
name: getTooltipName(geom, _origin),
value: getTooltipValue(geom, _origin),
title: getTooltipTitle(geom, _origin)
};
if (marker) {
tooltipItem.marker = Util.mix({
fill: color || Global.defaultColor
}, marker);
}
items.push(tooltipItem);

if ([ 'line', 'area', 'path' ].indexOf(type) !== -1) {
tooltipMarkerType = 'circle';
tooltipMarkerItems.push(tooltipItem);
} else if (type === 'interval' && coord.type === 'cartesian') {
tooltipMarkerType = 'rect';
tooltipItem.width = geom.getSize(record._origin);
tooltipMarkerItems.push(tooltipItem);
}
}
});
});
Expand Down

0 comments on commit cff0425

Please sign in to comment.