Skip to content

Commit

Permalink
Merge pull request #13379 from apache/next-merge-master
Browse files Browse the repository at this point in the history
Merge from master to next
  • Loading branch information
pissang authored Sep 30, 2020
2 parents 3f616bb + fb1196d commit a97faf2
Show file tree
Hide file tree
Showing 70 changed files with 4,640 additions and 308 deletions.
13 changes: 13 additions & 0 deletions .asf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github:
description: A powerful, interactive charting and data visualization library for browser
homepage: https://echarts.apache.org/
labels:
- echarts
- data-visualization
- charts
- charting-library
- visualization
- apache
- data-viz
- canvas
- svg
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# for pull request size bot
# excludes all files from test directory
test/** linguist-generated=true
5 changes: 5 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "npm run lint",
}
}
12 changes: 12 additions & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
path_classifiers:
test:
- test
library:
- benchmark/dep
generated:
- dist
extraction:
javascript:
index:
exclude:
- dist
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ECharts
# Apache ECharts (incubating)

<a href="https://echarts.apache.org/">
<img style="vertical-align: top;" src="./asset/logo.png?raw=true" alt="logo" height="50px">
</a>

ECharts is a free, powerful charting and visualization library offering an easy way of adding intuitive, interactive, and highly customizable charts to your commercial products. It is written in pure JavaScript and based on <a href="https://github.com/ecomfe/zrender">zrender</a>, which is a whole new lightweight canvas library.
Apache ECharts (incubating) is a free, powerful charting and visualization library offering an easy way of adding intuitive, interactive, and highly customizable charts to your commercial products. It is written in pure JavaScript and based on <a href="https://github.com/ecomfe/zrender">zrender</a>, which is a whole new lightweight canvas library.

Now ECharts is an incubator project of Apache Software Foundation.
Please check its incubator status [here](http://incubator.apache.org/projects/echarts.html)
Expand All @@ -13,7 +13,7 @@ Please check its incubator status [here](http://incubator.apache.org/projects/ec

[![Build Status](https://travis-ci.org/apache/incubator-echarts.svg?branch=master)](https://travis-ci.org/apache/incubator-echarts) [![](https://img.shields.io/npm/dw/echarts.svg?label=npm%20downloads&style=flat)](https://www.npmjs.com/package/echarts) [![Last npm release](https://img.shields.io/npm/v/echarts)](https://www.npmjs.com/package/echarts)

## Get ECharts
## Get Apache ECharts (incubating)

You may choose one of the following methods:

Expand All @@ -39,7 +39,7 @@ You may choose one of the following methods:
## Get Help

+ [GitHub Issues](https://github.com/apache/incubator-echarts/issues) for bug report and feature requests
+ Email [dev@echarts.apache.org](dev@echarts.apache.org) for general questions
+ Email [dev@echarts.apache.org](mailto:dev@echarts.apache.org) for general questions
+ Subscribe [mailing list](https://echarts.apache.org/en/maillist.html) to get updated with the project

## Build
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@microsoft/api-extractor": "7.7.2",
"@typescript-eslint/eslint-plugin": "^2.15.0",
"@typescript-eslint/parser": "^2.18.0",
"husky": "^4.2.5",
"canvas": "^2.6.0",
"chalk": "^3.0.0",
"chokidar": "^3.4.0",
Expand Down
92 changes: 61 additions & 31 deletions src/chart/bar/BarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
import BarSeriesModel, {BarSeriesOption, BarDataItemOption} from './BarSeries';
import type Axis2D from '../../coord/cartesian/Axis2D';
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
import type Polar from '../../coord/polar/Polar';
import type Model from '../../model/Model';
import { isCoordinateSystemType } from '../../coord/CoordinateSystem';
import { getDefaultLabel, getDefaultInterpolatedLabel } from '../helper/labelHelper';
Expand All @@ -79,28 +80,30 @@ type RectLayout = RectShape;

type BarPossiblePath = Sector | Rect | Sausage;

type CartesianCoordArea = ReturnType<Cartesian2D['getArea']>;
type PolarCoordArea = ReturnType<Polar['getArea']>;

function getClipArea(coord: CoordSysOfBar, data: List) {
let coordSysClipArea;
let coordSysClipArea = coord.getArea && coord.getArea();
if (isCoordinateSystemType<Cartesian2D>(coord, 'cartesian2d')) {
coordSysClipArea = coord.getArea && coord.getArea();
const baseAxis = coord.getBaseAxis();
// When boundaryGap is false or using time axis. bar may exceed the grid.
// We should not clip this part.
// See test/bar2.html
if (baseAxis.type !== 'category' || !baseAxis.onBand) {
const expandWidth = data.getLayout('bandWidth');
if (baseAxis.isHorizontal()) {
coordSysClipArea.x -= expandWidth;
coordSysClipArea.width += expandWidth * 2;
(coordSysClipArea as CartesianCoordArea).x -= expandWidth;
(coordSysClipArea as CartesianCoordArea).width += expandWidth * 2;
}
else {
coordSysClipArea.y -= expandWidth;
coordSysClipArea.height += expandWidth * 2;
(coordSysClipArea as CartesianCoordArea).y -= expandWidth;
(coordSysClipArea as CartesianCoordArea).height += expandWidth * 2;
}
}
}

return coordSysClipArea;
return coordSysClipArea as PolarCoordArea | CartesianCoordArea;
}

class BarView extends ChartView {
Expand Down Expand Up @@ -241,20 +244,24 @@ class BarView extends ChartView {
const defaultTextGetter = (values: ParsedValue | ParsedValue[]) => {
return getDefaultInterpolatedLabel(seriesModel.getData(), values);
};
function createBackground(dataIndex: number) {
const bgLayout = getLayout[coord.type](data, dataIndex);
const bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
(bgEl as Rect).setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
return bgEl;
};
data.diff(oldData)
.add(function (dataIndex) {
const itemModel = data.getItemModel<BarDataItemOption>(dataIndex);
const layout = getLayout[coord.type](data, dataIndex, itemModel);

if (drawBackground) {
const bgLayout = getLayout[coord.type](data, dataIndex);
const bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
(bgEl as Rect).setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
createBackground(dataIndex);
}

// If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
Expand Down Expand Up @@ -321,19 +328,19 @@ class BarView extends ChartView {
const layout = getLayout[coord.type](data, newIndex, itemModel);

if (drawBackground) {
const bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
(bgEl as Rect).setShape('r', barBorderRadius);
let bgEl: Rect | Sector;
if (oldBgEls.length === 0) {
bgEl = createBackground(oldIndex);
}
else {
bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
(bgEl as Rect).setShape('r', barBorderRadius);
}
bgEls[newIndex] = bgEl;
}
bgEls[newIndex] = bgEl;

const bgLayout = getLayout[coord.type](data, newIndex);
const shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
updateProps(
bgEl as Path, {shape: shape as RectShape}, animationModel, newIndex
);
}

let el = oldData.getItemGraphicEl(oldIndex) as BarPossiblePath;
Expand Down Expand Up @@ -595,12 +602,12 @@ class BarView extends ChartView {
}

interface Clipper {
(coordSysBoundingRect: RectLike, layout: RectLayout | SectorLayout): boolean
(coordSysBoundingRect: PolarCoordArea | CartesianCoordArea, layout: RectLayout | SectorLayout): boolean
}
const clip: {
[key in 'cartesian2d' | 'polar']: Clipper
} = {
cartesian2d(coordSysBoundingRect: RectLike, layout: Rect['shape']) {
cartesian2d(coordSysBoundingRect: CartesianCoordArea, layout: Rect['shape']) {
const signWidth = layout.width < 0 ? -1 : 1;
const signHeight = layout.height < 0 ? -1 : 1;
// Needs positive width and height
Expand Down Expand Up @@ -638,8 +645,31 @@ const clip: {
return clipped;
},

polar() {
return false;
polar(coordSysClipArea: PolarCoordArea, layout: Sector['shape']) {
const signR = layout.r0 <= layout.r ? 1 : -1;
// Make sure r is larger than r0
if (signR < 0) {
const tmp = layout.r;
layout.r = layout.r0;
layout.r0 = tmp;
}

const r = mathMin(layout.r, coordSysClipArea.r);
const r0 = mathMax(layout.r0, coordSysClipArea.r0);

layout.r = r;
layout.r0 = r0;

const clipped = r - r0 < 0;

// Reverse back
if (signR < 0) {
const tmp = layout.r;
layout.r = layout.r0;
layout.r0 = tmp;
}

return clipped;
}
};

Expand Down
10 changes: 8 additions & 2 deletions src/chart/funnel/FunnelSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import {
ItemStyleOption,
OptionDataValueNumeric,
StatesOptionMixin,
OptionDataItemObject
OptionDataItemObject,
LayoutOrient,
VerticalAlign
} from '../../util/types';
import GlobalModel from '../../model/Global';
import List from '../../data/List';
Expand All @@ -55,6 +57,7 @@ export interface FunnelDataItemOption
OptionDataItemObject<OptionDataValueNumeric> {

itemStyle?: ItemStyleOption & {
width?: number | string
height?: number | string
}
}
Expand All @@ -74,9 +77,11 @@ export interface FunnelSeriesOption extends SeriesOption<FunnelStateOption>, Fun

sort?: 'ascending' | 'descending' | 'none'

orient?: LayoutOrient

gap?: number

funnelAlign?: HorizontalAlign
funnelAlign?: HorizontalAlign | VerticalAlign

data?: (OptionDataValueNumeric | OptionDataValueNumeric[] | FunnelDataItemOption)[]
}
Expand Down Expand Up @@ -149,6 +154,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
minSize: '0%',
maxSize: '100%',
sort: 'descending', // 'ascending', 'descending'
orient: 'vertical',
gap: 0,
funnelAlign: 'center',
label: {
Expand Down
Loading

0 comments on commit a97faf2

Please sign in to comment.