From 27f05bfed3a555775ff9b3f8cb817515f441d5c3 Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Fri, 12 Mar 2021 16:13:47 +0800 Subject: [PATCH 1/7] feat: add polar attribute to heatmap --- docs/api/plots/heatmap.en.md | 4 ++ docs/api/plots/heatmap.zh.md | 5 +++ examples/heatmap/basic/demo/meta.json | 8 ++++ examples/heatmap/basic/demo/polar.ts | 61 +++++++++++++++++++++++++++ src/plots/heatmap/adaptor.ts | 20 ++++++++- src/plots/heatmap/types.ts | 2 + 6 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 examples/heatmap/basic/demo/polar.ts diff --git a/docs/api/plots/heatmap.en.md b/docs/api/plots/heatmap.en.md index ffbfdc1a86..55e62503fb 100644 --- a/docs/api/plots/heatmap.en.md +++ b/docs/api/plots/heatmap.en.md @@ -54,7 +54,11 @@ Axis mapping. **optional** _rect | square | circle_ Shapes in thermal grids, density heat maps are not specified. +#### polar +**optional** _true | false_ + +Whether or not we need polar coordinates, default false. #### sizeRatio **optional** _number_ diff --git a/docs/api/plots/heatmap.zh.md b/docs/api/plots/heatmap.zh.md index 407cc7216e..c8f611603c 100644 --- a/docs/api/plots/heatmap.zh.md +++ b/docs/api/plots/heatmap.zh.md @@ -54,6 +54,11 @@ order: 23 **可选** _rect | square | circle_ 热力格子中的形状,密度热力图不用指定。 +#### polar + +**可选** _true | false_ + +是否需要极坐标,默认 false。 #### sizeRatio diff --git a/examples/heatmap/basic/demo/meta.json b/examples/heatmap/basic/demo/meta.json index 01f52ed4b8..e5acb0a371 100644 --- a/examples/heatmap/basic/demo/meta.json +++ b/examples/heatmap/basic/demo/meta.json @@ -35,6 +35,14 @@ "en": "Calendar heatmap plot" }, "screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*aLbWR5ioU2UAAAAAAAAAAAAAARQnAQ" + }, + { + "filename": "polar.ts", + "title": { + "zh": "极坐标色块图", + "en": "Polar heatmap plot" + }, + "screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*cNrISYzITTcAAAAAAAAAAAAAARQnAQ" } ] } diff --git a/examples/heatmap/basic/demo/polar.ts b/examples/heatmap/basic/demo/polar.ts new file mode 100644 index 0000000000..a4248135df --- /dev/null +++ b/examples/heatmap/basic/demo/polar.ts @@ -0,0 +1,61 @@ +import { Heatmap } from '@antv/g2plot'; + +fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/polar-heatmap.json') + .then((res) => res.json()) + .then((data) => { + const heatmapPlot = new Heatmap(document.getElementById('container'), { + data, + xField: 'time', + yField: 'week', + colorField: 'value', + polar: true, // 极坐标属性 + legend: true, + color: '#BAE7FF-#1890FF-#1028ff', + heatmapStyle: { + stroke: '#f5f5f5', + opacity: 0.8, + }, + meta: { + time: { + type: 'cat', + }, + value: { + min: 0, + max: 1, + }, + }, + xAxis: { + line: null, + grid: null, + tickLine: null, + label: { + offset: 12, + style: { + fill: '#666', + fontSize: 12, + textBaseline: 'top', + }, + }, + }, + yAxis: { + top: true, + line: null, + grid: null, + tickLine: null, + label: { + offset: 0, + style: { + fill: '#fff', + textAlign: 'center', + shadowBlur: 2, + shadowColor: 'rgba(0, 0, 0, .45)', + }, + }, + }, + tooltip: { + showMarkers: false, + }, + interactions: [{ type: 'element-active' }], + }); + heatmapPlot.render(); + }); diff --git a/src/plots/heatmap/adaptor.ts b/src/plots/heatmap/adaptor.ts index 604ff91423..73766a5ecd 100644 --- a/src/plots/heatmap/adaptor.ts +++ b/src/plots/heatmap/adaptor.ts @@ -173,6 +173,23 @@ function label(params: Params): Params { return params; } +/** + * 极坐标 + * @param params + */ +function coordinate(params: Params): Params { + const { chart, options } = params; + const { polar } = options; + + if (polar) { + chart.coordinate('polar', { + innerRadius: 0.2, + }); + } + + return params; +} + /** * 热力图适配器 * @param chart @@ -192,6 +209,7 @@ export function adaptor(params: Params) { annotation(), interaction, animation, - state + state, + coordinate )(params); } diff --git a/src/plots/heatmap/types.ts b/src/plots/heatmap/types.ts index 61a7700829..d00e2a2f8b 100644 --- a/src/plots/heatmap/types.ts +++ b/src/plots/heatmap/types.ts @@ -19,4 +19,6 @@ export interface HeatmapOptions extends Options { readonly heatmapStyle?: StyleAttr; /** 坐标轴映射 */ readonly reflect?: 'x' | 'y'; + /** 极坐标属性 */ + readonly polar?: boolean; } From a952a795dbf8abfaed05890ef8bb356a7a78afdb Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Tue, 16 Mar 2021 17:04:14 +0800 Subject: [PATCH 2/7] feat: add polar attribute to heatmap add heatMap polar examples --- .../unit/plots/heatmap/coordinate-spec.ts | 71 +++++++++++++++++++ docs/api/plots/heatmap.en.md | 6 +- docs/api/plots/heatmap.zh.md | 6 +- examples/heatmap/basic/demo/polar.ts | 8 ++- src/plots/heatmap/adaptor.ts | 18 +++-- src/plots/heatmap/types.ts | 3 +- 6 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 __tests__/unit/plots/heatmap/coordinate-spec.ts diff --git a/__tests__/unit/plots/heatmap/coordinate-spec.ts b/__tests__/unit/plots/heatmap/coordinate-spec.ts new file mode 100644 index 0000000000..57f99bd228 --- /dev/null +++ b/__tests__/unit/plots/heatmap/coordinate-spec.ts @@ -0,0 +1,71 @@ +import { Heatmap } from '../../../../src'; +import { semanticBasicHeatmapData } from '../../../data/basic-heatmap'; +import { createDiv } from '../../../utils/dom'; + +describe('heatmap', () => { + it('x*y*color and default coordinate', () => { + const heatmap = new Heatmap(createDiv('default axis'), { + width: 400, + height: 300, + data: semanticBasicHeatmapData, + xField: 'name', + yField: 'day', + colorField: 'sales', + shape: 'circle', + coordinate: { + type: 'rect', + }, + }); + + heatmap.render(); + + // @ts-ignore + expect(heatmap.chart.options.coordinate.type).toBe('rect'); + + heatmap.destroy(); + }); + + it('x*y*color and custom axis', () => { + const heatmap = new Heatmap(createDiv('custom axis'), { + width: 400, + height: 300, + data: semanticBasicHeatmapData, + xField: 'name', + yField: 'day', + colorField: 'sales', + shape: 'circle', + coordinate: { + type: 'polar', + cfg: { + radius: 0.85, + innerRadius: 0.2, + }, + actions: [['rotate', 2]], + }, + }); + + heatmap.render(); + + // @ts-ignore + expect(heatmap.chart.options.coordinate.type).toBe('polar'); + // @ts-ignore + expect(heatmap.chart.options.coordinate.cfg.radius).toBe(0.85); + // @ts-ignore + expect(heatmap.chart.options.coordinate.cfg.innerRadius).toBe(0.2); + + heatmap.update({ + ...heatmap.options, + coordinate: { + type: 'rect', + actions: [['transpose']], + }, + }); + + // @ts-ignore + expect(heatmap.chart.options.coordinate.actions[0][0]).toBe('transpose'); + // @ts-ignore + expect(heatmap.chart.options.coordinate.type).toBe('rect'); + + heatmap.destroy(); + }); +}); diff --git a/docs/api/plots/heatmap.en.md b/docs/api/plots/heatmap.en.md index 55e62503fb..57ca9c9df3 100644 --- a/docs/api/plots/heatmap.en.md +++ b/docs/api/plots/heatmap.en.md @@ -54,11 +54,11 @@ Axis mapping. **optional** _rect | square | circle_ Shapes in thermal grids, density heat maps are not specified. -#### polar +#### coordinate -**optional** _true | false_ +**optional** -Whether or not we need polar coordinates, default false. +Coordinate system configuration property. #### sizeRatio **optional** _number_ diff --git a/docs/api/plots/heatmap.zh.md b/docs/api/plots/heatmap.zh.md index c8f611603c..aa01b3ed32 100644 --- a/docs/api/plots/heatmap.zh.md +++ b/docs/api/plots/heatmap.zh.md @@ -54,11 +54,11 @@ order: 23 **可选** _rect | square | circle_ 热力格子中的形状,密度热力图不用指定。 -#### polar +#### coordinate -**可选** _true | false_ +**可选** -是否需要极坐标,默认 false。 +坐标系配置属性。 #### sizeRatio diff --git a/examples/heatmap/basic/demo/polar.ts b/examples/heatmap/basic/demo/polar.ts index a4248135df..e2aee926fb 100644 --- a/examples/heatmap/basic/demo/polar.ts +++ b/examples/heatmap/basic/demo/polar.ts @@ -8,9 +8,15 @@ fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/polar-heatmap.json') xField: 'time', yField: 'week', colorField: 'value', - polar: true, // 极坐标属性 legend: true, color: '#BAE7FF-#1890FF-#1028ff', + coordinate: { + // 坐标轴属性配置 + type: 'polar', // 极坐标 + cfg: { + innerRadius: 0.2, + }, + }, heatmapStyle: { stroke: '#f5f5f5', opacity: 0.8, diff --git a/src/plots/heatmap/adaptor.ts b/src/plots/heatmap/adaptor.ts index 73766a5ecd..9590f7aece 100644 --- a/src/plots/heatmap/adaptor.ts +++ b/src/plots/heatmap/adaptor.ts @@ -13,7 +13,7 @@ import { HeatmapOptions } from './types'; */ function field(params: Params): Params { const { chart, options } = params; - const { data, type, reflect, xField, yField, colorField, sizeField, sizeRatio, shape, color } = options; + const { data, type, xField, yField, colorField, sizeField, sizeRatio, shape, color } = options; chart.data(data); let geometry: Geometry; @@ -28,10 +28,6 @@ function field(params: Params): Params { geometry.color(colorField, color || DEFAULT_COLORS.GRADIENT.CONTINUOUS); } - if (reflect) { - chart.coordinate().reflect(reflect); - } - /** * The ratio between the actual size and the max available size, must be in range `[0,1]`. * @@ -179,12 +175,14 @@ function label(params: Params): Params { */ function coordinate(params: Params): Params { const { chart, options } = params; - const { polar } = options; + const { coordinate, reflect } = options; - if (polar) { - chart.coordinate('polar', { - innerRadius: 0.2, - }); + if (reflect) { + chart.coordinate().reflect(reflect); + } + + if (coordinate) { + chart.coordinate(coordinate); } return params; diff --git a/src/plots/heatmap/types.ts b/src/plots/heatmap/types.ts index d00e2a2f8b..0dd85a1ca2 100644 --- a/src/plots/heatmap/types.ts +++ b/src/plots/heatmap/types.ts @@ -1,3 +1,4 @@ +import { Types } from '@antv/g2'; import { Options, StyleAttr } from '../../types'; export interface HeatmapOptions extends Options { @@ -20,5 +21,5 @@ export interface HeatmapOptions extends Options { /** 坐标轴映射 */ readonly reflect?: 'x' | 'y'; /** 极坐标属性 */ - readonly polar?: boolean; + readonly coordinate?: Types.CoordinateOption; } From 6dbecde41952c76b2de36ef344010f96c2ec4e0c Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Tue, 16 Mar 2021 17:09:05 +0800 Subject: [PATCH 3/7] feat: add polar attribute to heatmap add heatMap polar examples --- docs/api/plots/heatmap.en.md | 2 ++ docs/api/plots/heatmap.zh.md | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/api/plots/heatmap.en.md b/docs/api/plots/heatmap.en.md index 57ca9c9df3..14b81c1fee 100644 --- a/docs/api/plots/heatmap.en.md +++ b/docs/api/plots/heatmap.en.md @@ -54,11 +54,13 @@ Axis mapping. **optional** _rect | square | circle_ Shapes in thermal grids, density heat maps are not specified. + #### coordinate **optional** Coordinate system configuration property. + #### sizeRatio **optional** _number_ diff --git a/docs/api/plots/heatmap.zh.md b/docs/api/plots/heatmap.zh.md index aa01b3ed32..0c090243f1 100644 --- a/docs/api/plots/heatmap.zh.md +++ b/docs/api/plots/heatmap.zh.md @@ -54,6 +54,7 @@ order: 23 **可选** _rect | square | circle_ 热力格子中的形状,密度热力图不用指定。 + #### coordinate **可选** From 1e5b1698471a6feffd5f11108ce1c46a77b8583a Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Wed, 17 Mar 2021 14:27:26 +0800 Subject: [PATCH 4/7] feat: add polar attribute to heatmap add heatMap polar examples -2 --- .../unit/plots/heatmap/coordinate-spec.ts | 15 +++++++------ docs/api/plots/heatmap.en.md | 21 +++++++++++++++++++ docs/api/plots/heatmap.zh.md | 21 +++++++++++++++++++ src/plots/heatmap/adaptor.ts | 5 ++++- src/plots/heatmap/index.ts | 3 +++ 5 files changed, 56 insertions(+), 9 deletions(-) diff --git a/__tests__/unit/plots/heatmap/coordinate-spec.ts b/__tests__/unit/plots/heatmap/coordinate-spec.ts index 57f99bd228..95b46e41fd 100644 --- a/__tests__/unit/plots/heatmap/coordinate-spec.ts +++ b/__tests__/unit/plots/heatmap/coordinate-spec.ts @@ -12,9 +12,6 @@ describe('heatmap', () => { yField: 'day', colorField: 'sales', shape: 'circle', - coordinate: { - type: 'rect', - }, }); heatmap.render(); @@ -40,7 +37,6 @@ describe('heatmap', () => { radius: 0.85, innerRadius: 0.2, }, - actions: [['rotate', 2]], }, }); @@ -56,15 +52,18 @@ describe('heatmap', () => { heatmap.update({ ...heatmap.options, coordinate: { - type: 'rect', - actions: [['transpose']], + type: 'polar', + cfg: { + startAngle: 1, + endAngle: 2, + }, }, }); // @ts-ignore - expect(heatmap.chart.options.coordinate.actions[0][0]).toBe('transpose'); + expect(heatmap.chart.options.coordinate.cfg.startAngle).toBe(1); // @ts-ignore - expect(heatmap.chart.options.coordinate.type).toBe('rect'); + expect(heatmap.chart.options.coordinate.cfg.endAngle).toBe(2); heatmap.destroy(); }); diff --git a/docs/api/plots/heatmap.en.md b/docs/api/plots/heatmap.en.md index 14b81c1fee..cbc6eb1bcf 100644 --- a/docs/api/plots/heatmap.en.md +++ b/docs/api/plots/heatmap.en.md @@ -61,6 +61,27 @@ Shapes in thermal grids, density heat maps are not specified. Coordinate system configuration property. +| Properties | Type | Whether the choice | Default | Description | +| ------- | --------------------- | -------- | ------ | ------------------------------ | +| type | string | | 'rect' | Type of coordinate system | +| cfg | _CoordinateCfg_ | | - | Coordinate system configuration term, currently commonly used in polar coordinates | + +_**CoordinateOption.type**_ Type of coordinate system: + +- cartesian / rect:Cartesian coordinate system +- polar:Polar coordinates +- helix:Spiral coordinate system, based on Archimedes helix +- theta:A special polar coordinate system with fixed radius lengths that maps data only to angles, often used in pie charts + +_**CoordinateCfg**_ Coordinate system configuration term, currently commonly used in polar coordinates: + +| Properties | Type | Whether the choice | Default | Description | +| ----------- | -------- | -------- | ------ | ------------------------------------------ | +| startAngle | _number_ | | - | For polar coordinates, configure the starting radian | +| endAngle | _number_ | | - | For polar coordinates, configure end radians | +| radius | _number_ | | - | For polar coordinates, configure polar radius, values in the 0-1 range | +| innerRadius | _number_ | | - | For polar coordinates, radius within polar coordinates, values in the range 0-1 | + #### sizeRatio **optional** _number_ diff --git a/docs/api/plots/heatmap.zh.md b/docs/api/plots/heatmap.zh.md index 0c090243f1..50672dd2a1 100644 --- a/docs/api/plots/heatmap.zh.md +++ b/docs/api/plots/heatmap.zh.md @@ -61,6 +61,27 @@ order: 23 坐标系配置属性。 +| 参数名 | 类型 | 是否必选 | 默认值 | 描述 | +| ------- | --------------------- | -------- | ------ | ----------------------------| +| type | string | | 'rect' | 坐标系类型 | +| cfg | _CoordinateCfg_ | | - | 坐标系配置项,目前常用于极坐标 | + +_**CoordinateOption.type**_ 坐标系类型: + +- cartesian / rect:笛卡尔坐标系 +- polar:极坐标系 +- helix:螺旋坐标系,基于阿基米德螺旋线 +- theta:一种特殊的极坐标系,半径长度固定,仅仅将数据映射到角度,常用于饼图的绘制 + +_**CoordinateCfg**_ 坐标系配置项,目前常用于极坐标: + +| 参数名 | 类型 | 是否必选 | 默认值 | 描述 | +| ----------- | -------- | -------- | ------ | ----------------------------------------| +| startAngle | _number_ | | - | 用于极坐标,配置起始弧度 | +| endAngle | _number_ | | - | 用于极坐标,配置结束弧度 | +| radius | _number_ | | - | 用于极坐标,配置极坐标半径,0-1 范围的数值 | +| innerRadius | _number_ | | - | 用于极坐标,极坐标内半径,0 -1 范围的数值 | + #### sizeRatio **可选** _number_ diff --git a/src/plots/heatmap/adaptor.ts b/src/plots/heatmap/adaptor.ts index 9590f7aece..b535162036 100644 --- a/src/plots/heatmap/adaptor.ts +++ b/src/plots/heatmap/adaptor.ts @@ -182,7 +182,10 @@ function coordinate(params: Params): Params { } if (coordinate) { - chart.coordinate(coordinate); + chart.coordinate({ + type: coordinate?.type || 'rect', + cfg: coordinate?.cfg, + }); } return params; diff --git a/src/plots/heatmap/index.ts b/src/plots/heatmap/index.ts index ff96b47e4a..6f59a2d49d 100644 --- a/src/plots/heatmap/index.ts +++ b/src/plots/heatmap/index.ts @@ -24,6 +24,9 @@ export class Heatmap extends Plot { return deepAssign({}, super.getDefaultOptions(), { type: 'polygon', legend: false, + coordinate: { + type: 'rect', + }, xAxis: { tickLine: null, line: null, From 84d22af275dbf794e2e3065f9689f449b5c4f874 Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Wed, 17 Mar 2021 15:08:08 +0800 Subject: [PATCH 5/7] feat: add polar attribute add heatMap polar examples add document --- docs/api/plots/heatmap.en.md | 20 ++++++++++---------- docs/api/plots/heatmap.zh.md | 20 ++++++++++---------- src/plots/heatmap/adaptor.ts | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/api/plots/heatmap.en.md b/docs/api/plots/heatmap.en.md index cbc6eb1bcf..b099eeb214 100644 --- a/docs/api/plots/heatmap.en.md +++ b/docs/api/plots/heatmap.en.md @@ -61,10 +61,10 @@ Shapes in thermal grids, density heat maps are not specified. Coordinate system configuration property. -| Properties | Type | Whether the choice | Default | Description | -| ------- | --------------------- | -------- | ------ | ------------------------------ | -| type | string | | 'rect' | Type of coordinate system | -| cfg | _CoordinateCfg_ | | - | Coordinate system configuration term, currently commonly used in polar coordinates | +| Properties | Type | Default | Description | +| ------- | --------------------- | ------ | ------------------------------ | +| type | string | 'rect' | Type of coordinate system | +| cfg | _CoordinateCfg_ | - | Coordinate system configuration term, currently commonly used in polar coordinates | _**CoordinateOption.type**_ Type of coordinate system: @@ -75,12 +75,12 @@ _**CoordinateOption.type**_ Type of coordinate system: _**CoordinateCfg**_ Coordinate system configuration term, currently commonly used in polar coordinates: -| Properties | Type | Whether the choice | Default | Description | -| ----------- | -------- | -------- | ------ | ------------------------------------------ | -| startAngle | _number_ | | - | For polar coordinates, configure the starting radian | -| endAngle | _number_ | | - | For polar coordinates, configure end radians | -| radius | _number_ | | - | For polar coordinates, configure polar radius, values in the 0-1 range | -| innerRadius | _number_ | | - | For polar coordinates, radius within polar coordinates, values in the range 0-1 | +| Properties | Type | Default | Description | +| ----------- | -------- |------ | ------------------------------------------ | +| startAngle | _number_ | | For polar coordinates, configure the starting radian | +| endAngle | _number_ | | For polar coordinates, configure end radians | +| radius | _number_ | | For polar coordinates, configure polar radius, values in the 0-1 range | +| innerRadius | _number_ | | For polar coordinates, radius within polar coordinates, values in the range 0-1 | #### sizeRatio diff --git a/docs/api/plots/heatmap.zh.md b/docs/api/plots/heatmap.zh.md index 50672dd2a1..7b06ce95e5 100644 --- a/docs/api/plots/heatmap.zh.md +++ b/docs/api/plots/heatmap.zh.md @@ -61,10 +61,10 @@ order: 23 坐标系配置属性。 -| 参数名 | 类型 | 是否必选 | 默认值 | 描述 | -| ------- | --------------------- | -------- | ------ | ----------------------------| -| type | string | | 'rect' | 坐标系类型 | -| cfg | _CoordinateCfg_ | | - | 坐标系配置项,目前常用于极坐标 | +| 参数名 | 类型 | 默认值 | 描述 | +| ------- | --------------------- | ------ | ----------------------------| +| type | string | 'rect' | 坐标系类型 | +| cfg | _CoordinateCfg_ | - | 坐标系配置项,目前常用于极坐标 | _**CoordinateOption.type**_ 坐标系类型: @@ -75,12 +75,12 @@ _**CoordinateOption.type**_ 坐标系类型: _**CoordinateCfg**_ 坐标系配置项,目前常用于极坐标: -| 参数名 | 类型 | 是否必选 | 默认值 | 描述 | -| ----------- | -------- | -------- | ------ | ----------------------------------------| -| startAngle | _number_ | | - | 用于极坐标,配置起始弧度 | -| endAngle | _number_ | | - | 用于极坐标,配置结束弧度 | -| radius | _number_ | | - | 用于极坐标,配置极坐标半径,0-1 范围的数值 | -| innerRadius | _number_ | | - | 用于极坐标,极坐标内半径,0 -1 范围的数值 | +| 参数名 | 类型 | 默认值 | 描述 | +| ----------- | -------- | ------ | ----------------------------------------| +| startAngle | _number_ | - | 用于极坐标,配置起始弧度 | +| endAngle | _number_ | - | 用于极坐标,配置结束弧度 | +| radius | _number_ | - | 用于极坐标,配置极坐标半径,0-1 范围的数值 | +| innerRadius | _number_ | - | 用于极坐标,极坐标内半径,0 -1 范围的数值 | #### sizeRatio diff --git a/src/plots/heatmap/adaptor.ts b/src/plots/heatmap/adaptor.ts index b535162036..2c123e6137 100644 --- a/src/plots/heatmap/adaptor.ts +++ b/src/plots/heatmap/adaptor.ts @@ -177,10 +177,6 @@ function coordinate(params: Params): Params { const { chart, options } = params; const { coordinate, reflect } = options; - if (reflect) { - chart.coordinate().reflect(reflect); - } - if (coordinate) { chart.coordinate({ type: coordinate?.type || 'rect', @@ -188,6 +184,10 @@ function coordinate(params: Params): Params { }); } + if (reflect) { + chart.coordinate().reflect(reflect); + } + return params; } From 548a0433161437e0d602e85165aa10750dd02ab3 Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Wed, 17 Mar 2021 16:13:14 +0800 Subject: [PATCH 6/7] feat: add polar attribute add heatMap polar examples add document --- src/plots/heatmap/adaptor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plots/heatmap/adaptor.ts b/src/plots/heatmap/adaptor.ts index 2c123e6137..f754b9a333 100644 --- a/src/plots/heatmap/adaptor.ts +++ b/src/plots/heatmap/adaptor.ts @@ -179,8 +179,8 @@ function coordinate(params: Params): Params { if (coordinate) { chart.coordinate({ - type: coordinate?.type || 'rect', - cfg: coordinate?.cfg, + type: coordinate.type || 'rect', + cfg: coordinate.cfg, }); } From bfeb152b48f63f38cfefc591b6c710156e6fb504 Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Wed, 17 Mar 2021 16:17:39 +0800 Subject: [PATCH 7/7] feat: add polar attribute add heatMap polar examples add document --- docs/api/plots/heatmap.en.md | 20 ++++++++++---------- docs/api/plots/heatmap.zh.md | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/api/plots/heatmap.en.md b/docs/api/plots/heatmap.en.md index b099eeb214..32ef09c3c5 100644 --- a/docs/api/plots/heatmap.en.md +++ b/docs/api/plots/heatmap.en.md @@ -61,10 +61,10 @@ Shapes in thermal grids, density heat maps are not specified. Coordinate system configuration property. -| Properties | Type | Default | Description | -| ------- | --------------------- | ------ | ------------------------------ | -| type | string | 'rect' | Type of coordinate system | -| cfg | _CoordinateCfg_ | - | Coordinate system configuration term, currently commonly used in polar coordinates | +| Properties | Type | Description | +| ------- | --------------------- | ------------------------------ | +| type | string | Type of coordinate system | +| cfg | _CoordinateCfg_ | Coordinate system configuration term, currently commonly used in polar coordinates | _**CoordinateOption.type**_ Type of coordinate system: @@ -75,12 +75,12 @@ _**CoordinateOption.type**_ Type of coordinate system: _**CoordinateCfg**_ Coordinate system configuration term, currently commonly used in polar coordinates: -| Properties | Type | Default | Description | -| ----------- | -------- |------ | ------------------------------------------ | -| startAngle | _number_ | | For polar coordinates, configure the starting radian | -| endAngle | _number_ | | For polar coordinates, configure end radians | -| radius | _number_ | | For polar coordinates, configure polar radius, values in the 0-1 range | -| innerRadius | _number_ | | For polar coordinates, radius within polar coordinates, values in the range 0-1 | +| Properties | Type | Description | +| ----------- | -------- | ------------------------------------------ | +| startAngle | _number_ | For polar coordinates, configure the starting radian | +| endAngle | _number_ | For polar coordinates, configure end radians | +| radius | _number_ | For polar coordinates, configure polar radius, values in the 0-1 range | +| innerRadius | _number_ | For polar coordinates, radius within polar coordinates, values in the range 0-1 | #### sizeRatio diff --git a/docs/api/plots/heatmap.zh.md b/docs/api/plots/heatmap.zh.md index 7b06ce95e5..85abd34219 100644 --- a/docs/api/plots/heatmap.zh.md +++ b/docs/api/plots/heatmap.zh.md @@ -61,10 +61,10 @@ order: 23 坐标系配置属性。 -| 参数名 | 类型 | 默认值 | 描述 | -| ------- | --------------------- | ------ | ----------------------------| -| type | string | 'rect' | 坐标系类型 | -| cfg | _CoordinateCfg_ | - | 坐标系配置项,目前常用于极坐标 | +| 参数名 | 类型 | 描述 | +| ------- | --------------------- | ----------------------------| +| type | string | 坐标系类型 | +| cfg | _CoordinateCfg_ | 坐标系配置项,目前常用于极坐标 | _**CoordinateOption.type**_ 坐标系类型: @@ -75,12 +75,12 @@ _**CoordinateOption.type**_ 坐标系类型: _**CoordinateCfg**_ 坐标系配置项,目前常用于极坐标: -| 参数名 | 类型 | 默认值 | 描述 | -| ----------- | -------- | ------ | ----------------------------------------| -| startAngle | _number_ | - | 用于极坐标,配置起始弧度 | -| endAngle | _number_ | - | 用于极坐标,配置结束弧度 | -| radius | _number_ | - | 用于极坐标,配置极坐标半径,0-1 范围的数值 | -| innerRadius | _number_ | - | 用于极坐标,极坐标内半径,0 -1 范围的数值 | +| 参数名 | 类型 | 描述 | +| ----------- | -------- | ----------------------------------------| +| startAngle | _number_ | 用于极坐标,配置起始弧度 | +| endAngle | _number_ | 用于极坐标,配置结束弧度 | +| radius | _number_ | 用于极坐标,配置极坐标半径,0-1 范围的数值 | +| innerRadius | _number_ | 用于极坐标,极坐标内半径,0 -1 范围的数值 | #### sizeRatio