Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rowValues.forEach((yVal, yIndex) => {
const conditions = [
{ field: columnField, value: xVal, values: columnValues },
{ field: rowField, value: yVal, values: rowValues },
];
const facetData = filter(data, (datum: Datum) => {
// 过滤出全部满足条件的数据
return every(conditions, (condition) => {
const { field, value } = condition;
return datum[field] === value;
});
});
const facet: RectData = {
type: this.cfg.type,
data: facetData,
region: this.getRegion(rowValuesLength, columnValuesLength, xIndex, yIndex),
columnValue: xVal,
rowValue: yVal,
columnField,
rowField,
export function getPathPoints(points: ShapeVertices, connectNulls?: boolean) {
if (!points.length) {
return [];
}
if (connectNulls) {
// 即 y 值为空的场景
const filtered = filter(points, (point: RangePoint | Point[]) => {
return !isYNil(point);
});
return [filtered];
}
const result = [];
let tmp = [];
points.forEach((point: RangePoint | Point[]) => {
if (isYNil(point)) {
if (tmp.length) {
result.push(tmp);
tmp = [];
}
} else {
tmp.push(point);
}
private _getDefaultTooltipOptions() {
const view = this.view;
const options = this.options;
const theme = this.theme;
const defaultCfg = _.mix({}, theme.tooltip);
const elements = _.filter(view.getElements(), (element: Element): boolean => element.get('visible'));
const shapes = _.uniq(_.map(elements, (element: Element) => element.get('type')));
const isTransposed = view.get('coord') ? view.get('coord').isTransposed : false;
let crosshairsCfg;
if (view.get('coord') && view.get('coord').type === 'cartesian') {
if (shapes[0] === 'interval') {
if (options.shape !== false) {
const crosshairs = _.mix({}, theme.tooltipCrosshairsRect);
crosshairs.isTransposed = isTransposed;
crosshairsCfg = {
zIndex: 0, // 矩形背景框不可覆盖 geom
crosshairs,
};
}
} else if (_.indexOf(TYPE_SHOW_CROSSHAIRS, shapes[0]) > -1) {
function calcVisibleRate(labelShapes: Shape[], div: HTMLElement) {
const visibleLabels: Shape[] = _.filter(labelShapes, (l) => l.get('visible'));
const visibleRate = visibleLabels.length / labelShapes.length;
div.innerHTML = `label 可见率: ${visibleRate * 100}%`;
return visibleRate;
}
public getLabels() {
const container = this.get('container');
if (container) {
return Util.toArray(container.childNodes);
}
const children = this.get('group').get('children');
return Util.filter(children, (child: any) => child.isShape);
}
function getAttributesForLegend(geometry: Geometry) {
const attributes = values(geometry.attributes);
return filter(attributes, (attribute: Attribute) => contains(GROUP_ATTRS, attribute.type));
}