Comparing version 3.0.4-beta.3 to 3.0.4-beta.4
{ | ||
"name": "@antv/g2", | ||
"version": "3.0.4-beta.3", | ||
"version": "3.0.4-beta.4", | ||
"description": "the Grammar of Graphics in Javascript", | ||
@@ -5,0 +5,0 @@ "main": "build/g2.js", |
@@ -40,2 +40,5 @@ /** | ||
function calColor(colors, percent) { | ||
if (Util.isNaN(percent) || !Util.isNumber(percent)) { | ||
percent = 0; | ||
} | ||
const steps = colors.length - 1; | ||
@@ -42,0 +45,0 @@ const step = Math.floor(steps * percent); |
@@ -227,3 +227,3 @@ /** | ||
const scale = attr.getScale(type); | ||
if (scale.type !== 'identity' && !_isScaleExist(scales, scale)) { | ||
if (scale.field && scale.type !== 'identity' && !_isScaleExist(scales, scale)) { | ||
scales.push(scale); | ||
@@ -280,3 +280,3 @@ const filteredValues = view.getFilteredValues(scale.field); | ||
const width = DomUtil.getWidth(container, oldWidth); | ||
if (width !== oldWidth) { | ||
if (width !== 0 && width !== oldWidth) { | ||
const height = self.get('height'); | ||
@@ -283,0 +283,0 @@ self.changeSize(width, height); |
@@ -186,22 +186,23 @@ /** | ||
} | ||
chart.emit('tooltip:change', { | ||
tooltip, | ||
x, | ||
y, | ||
items | ||
}); | ||
// bugfix: when set the title in the tooltip:change event does not take effect. | ||
const first = items[0]; | ||
const title = first.title || first.name; | ||
tooltip.setContent(title, items); | ||
if (!Util.isEmpty(markersItems)) { | ||
if (self.options.hideMarkers === true) { // 不展示 tooltip marker | ||
tooltip.set('markerItems', markersItems); // 用于 tooltip 辅助线的定位 | ||
// bugfix: when set the title in the tooltip:change event does not take effect. | ||
if (tooltip.isContentChange(title, items)) { | ||
chart.emit('tooltip:change', { | ||
tooltip, | ||
x, | ||
y, | ||
items | ||
}); | ||
tooltip.setContent(title, items); | ||
if (!Util.isEmpty(markersItems)) { | ||
if (self.options.hideMarkers === true) { // 不展示 tooltip marker | ||
tooltip.set('markerItems', markersItems); // 用于 tooltip 辅助线的定位 | ||
} else { | ||
tooltip.setMarkers(markersItems, Global.tooltipMarker); | ||
} | ||
} else { | ||
tooltip.setMarkers(markersItems, Global.tooltipMarker); | ||
tooltip.clearMarkers(); | ||
} | ||
} else { | ||
tooltip.clearMarkers(); | ||
} | ||
tooltip.setPosition(x, y, target); | ||
@@ -208,0 +209,0 @@ tooltip.show(); |
@@ -911,4 +911,4 @@ /** | ||
this.beforeRender(); | ||
this.emit('beforepaint'); | ||
this.drawComponents(); | ||
this.emit('beforepaint'); | ||
this.paint(); | ||
@@ -915,0 +915,0 @@ this.emit('afterpaint'); |
@@ -369,3 +369,3 @@ /** | ||
_isContentChange(title, items) { | ||
isContentChange(title, items) { | ||
const titleContent = this.get('titleContent'); | ||
@@ -388,10 +388,11 @@ const lastItems = this.get('items'); | ||
setContent(title, items) { | ||
const isChange = this._isContentChange(title, items); | ||
if (isChange) { | ||
const timeStamp = +new Date(); | ||
this.set('items', items); | ||
this.set('titleContent', title); | ||
this.set('timeStamp', timeStamp); | ||
this._renderTooltip(); | ||
} | ||
// const isChange = this.isContentChange(title, items); | ||
// if (isChange) { | ||
// 在外面进行判断是否内容发生改变 | ||
const timeStamp = +new Date(); | ||
this.set('items', items); | ||
this.set('titleContent', title); | ||
this.set('timeStamp', timeStamp); | ||
this._renderTooltip(); | ||
// } | ||
return this; | ||
@@ -406,3 +407,4 @@ } | ||
markerGroup = frontPlot.addGroup({ | ||
zIndex: 1 | ||
zIndex: 1, | ||
capture: false // 不进行拾取 | ||
}); | ||
@@ -409,0 +411,0 @@ self.set('markerGroup', markerGroup); |
@@ -75,3 +75,3 @@ /** | ||
textAlign: 'center', | ||
fill: '#444', | ||
fill: '#666', | ||
fontFamily: Global.fontFamily | ||
@@ -86,3 +86,3 @@ } | ||
rotate: 90, | ||
fill: '#444', | ||
fill: '#666', | ||
fontFamily: Global.fontFamily | ||
@@ -89,0 +89,0 @@ } |
@@ -10,5 +10,10 @@ /** | ||
const ShapeUtil = require('../util/shape'); | ||
const Marker = require('@antv/g').Marker; | ||
const Global = require('../../global'); | ||
const Shape = require('./shape'); | ||
// const svgpath = require('svgpath'); | ||
const { | ||
Marker, | ||
PathUtil | ||
} = require('@antv/g'); | ||
const SHAPES = [ 'circle', 'square', 'bowtie', 'diamond', 'hexagon', 'triangle', 'triangle-down' ]; | ||
@@ -120,6 +125,6 @@ const HOLLOW_SHAPES = [ 'cross', 'tick', 'plus', 'hyphen', 'line', 'pointerLine', 'pointerArrow' ]; | ||
const path = [[ 'M', x - 0.5 * w, y - 0.5 * h ], | ||
[ 'L', x + 0.5 * w, y - 0.5 * h ], | ||
[ 'L', x + 0.5 * w, y + 0.5 * h ], | ||
[ 'L', x - 0.5 * w, y + 0.5 * h ], | ||
[ 'z' ]]; | ||
[ 'L', x + 0.5 * w, y - 0.5 * h ], | ||
[ 'L', x + 0.5 * w, y + 0.5 * h ], | ||
[ 'L', x - 0.5 * w, y + 0.5 * h ], | ||
[ 'z' ]]; | ||
return path; | ||
@@ -214,2 +219,83 @@ } | ||
// image | ||
Shape.registerShape('point', 'image', { | ||
draw(cfg, container) { | ||
cfg.points = this.parsePoints(cfg.points); | ||
return container.addShape('image', { | ||
attrs: { | ||
x: cfg.points[0].x - (cfg.size / 2), | ||
y: cfg.points[0].y - cfg.size, | ||
width: cfg.size, | ||
height: cfg.size, | ||
img: cfg.shape[1] | ||
} | ||
}); | ||
} | ||
}); | ||
// const pathRangeCache = {}; | ||
// function getUnifiedPath(path, cfg) { | ||
// let pathRange; | ||
// if (pathRangeCache[path]) { | ||
// pathRange = pathRangeCache[path]; | ||
// } else { | ||
// const segments = PathUtil.parsePathString(path); | ||
// const nums = Util.flatten(segments).filter(num => Util.isNumber(num)); | ||
// pathRangeCache[path] = pathRange = Math.max.apply(null, nums) - Math.min.apply(null, nums); | ||
// } | ||
// | ||
// const size = cfg.size || 10; | ||
// const scale = size / pathRange; | ||
// const transformed = svgpath(path) | ||
// .scale(scale) | ||
// .translate(cfg.x, cfg.y); | ||
// if (cfg.style && cfg.style.rotate) { | ||
// transformed.rotate(cfg.style.rotate, cfg.x, cfg.y); | ||
// } | ||
// return PathUtil.parsePathString(transformed.toString()); | ||
// } | ||
// path | ||
const pathMetaCache = {}; | ||
Shape.registerShape('point', 'path', { | ||
draw(cfg, container) { | ||
const attrs = Util.mix({}, getLineAttrs(cfg), getFillAttrs(cfg)); | ||
// const unifiedPathArray = getUnifiedPath(cfg.shape[1], cfg); | ||
// return container.addShape('path', { | ||
// attrs: Util.mix(attrs, { | ||
// path: unifiedPathArray | ||
// }) | ||
// }); | ||
const path = cfg.shape[1]; | ||
const size = cfg.size || 10; | ||
let pathMeta; | ||
if (pathMetaCache[path]) { | ||
pathMeta = pathMetaCache[path]; | ||
} else { | ||
const segments = PathUtil.parsePathString(path); | ||
const nums = Util.flatten(segments).filter(num => Util.isNumber(num)); | ||
pathMetaCache[path] = pathMeta = { | ||
range: Math.max.apply(null, nums) - Math.min.apply(null, nums), | ||
segments | ||
}; | ||
} | ||
const scale = size / pathMeta.range; | ||
const transform = []; | ||
if (attrs.rotate) { | ||
transform.push([ 'r', attrs.rotate / 180 * Math.PI ]); | ||
delete attrs.rotate; | ||
} | ||
const shape = container.addShape('path', { | ||
attrs: Util.mix(attrs, { | ||
path: pathMeta.segments | ||
}) | ||
}); | ||
transform.push([ 's', scale, scale ], [ 't', cfg.x, cfg.y ]); | ||
shape.transform(transform); | ||
return shape; | ||
} | ||
}); | ||
module.exports = Point; |
@@ -109,5 +109,7 @@ /** | ||
} | ||
return shape.getMarkerCfg(cfg); | ||
}, | ||
getSelectedCfg(/* type, cfg */) { | ||
return {}; | ||
}, | ||
drawShape(type, cfg, container) { | ||
@@ -114,0 +116,0 @@ const shape = this.getShape(type); |
@@ -18,34 +18,36 @@ /** | ||
const Util = { | ||
assign: require('lodash/assign'), | ||
cloneDeep: require('lodash/cloneDeep'), | ||
each: require('lodash/each'), | ||
map: require('lodash/map'), | ||
isObject: require('lodash/isObject'), | ||
isNumber: require('lodash/isNumber'), | ||
isString: require('lodash/isString'), | ||
isFunction: require('lodash/isFunction'), | ||
isFinite: require('lodash/isFinite'), | ||
filter: require('lodash/filter'), | ||
flatten: require('lodash/flatten'), | ||
groupBy: require('lodash/groupBy'), | ||
indexOf: require('lodash/indexOf'), | ||
isArray: require('lodash/isArray'), | ||
isBoolean: require('lodash/isBoolean'), | ||
isDate: require('lodash/isDate'), | ||
isEmpty: require('lodash/isEmpty'), | ||
lowerFirst: require('lodash/lowerFirst'), | ||
upperFirst: require('lodash/upperFirst'), | ||
upperCase: require('lodash/upperCase'), | ||
isEqual: require('lodash/isEqual'), | ||
isEqualWith: require('lodash/isEqualWith'), | ||
isFinite: require('lodash/isFinite'), | ||
isFunction: require('lodash/isFunction'), | ||
isNaN: require('lodash/isNaN'), | ||
isNil: require('lodash/isNil'), | ||
isNull: require('lodash/isNull'), | ||
isArray: require('lodash/isArray'), | ||
isDate: require('lodash/isDate'), | ||
isNumber: require('lodash/isNumber'), | ||
isObject: require('lodash/isObject'), | ||
isPlainObject: require('lodash/isPlainObject'), | ||
toArray: require('lodash/toArray'), | ||
indexOf: require('lodash/indexOf'), | ||
assign: require('lodash/assign'), | ||
groupBy: require('lodash/groupBy'), | ||
cloneDeep: require('lodash/cloneDeep'), | ||
isString: require('lodash/isString'), | ||
lowerFirst: require('lodash/lowerFirst'), | ||
map: require('lodash/map'), | ||
maxBy: require('lodash/maxBy'), | ||
minBy: require('lodash/minBy'), | ||
pick: require('lodash/pick'), | ||
replace: require('lodash/replace'), | ||
round: require('lodash/round'), | ||
filter: require('lodash/filter'), | ||
isEqualWith: require('lodash/isEqualWith'), | ||
isEqual: require('lodash/isEqual'), | ||
replace: require('lodash/replace'), | ||
toArray: require('lodash/toArray'), | ||
union: require('lodash/union'), | ||
pick: require('lodash/pick'), | ||
uniq: require('lodash/uniq'), | ||
upperCase: require('lodash/upperCase'), | ||
upperFirst: require('lodash/upperFirst'), | ||
snapEqual(v1, v2) { | ||
@@ -52,0 +54,0 @@ return Math.abs(v1 - v2) < 0.001; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4358679
63686