From 25de7baa650904507a53e9fdd50e9c6374ea1c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=A5=E6=98=95?= Date: Mon, 19 Apr 2021 15:18:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7g2&g2Plot=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E8=87=AA=E5=AE=9A=E4=B9=89scale=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=EF=BC=9Bfix=EF=BC=9A=E6=95=B0=E6=8D=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BC=98=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demos/funnel/basicFunnel.jsx | 2 +- demos/interval/bezier.jsx | 2 +- demos/plot/ring.jsx | 2 +- package.json | 8 +- src/components/Chart/chartHelper.ts | 4 + src/components/Facet/index.tsx | 4 + src/core.ts | 2 +- .../components/Chart-data-update-spec.tsx | 300 +++++++++ unittest/components/Chart-spec.tsx | 2 +- unittest/components/Facet-spec.tsx | 616 ++++++++++++++++++ unittest/components/react-tooltip-spec.tsx | 192 ++++++ unittest/plots-base/BasePlot-spec.tsx | 2 +- unittest/plots/CalendarChart-spec.tsx | 4 +- unittest/plots/HeatmapChart-spec.tsx | 2 +- unittest/plots/PieChart-spec.tsx | 2 +- unittest/plots/RingProgressChart-spec.tsx | 2 +- unittest/plots/WordCloudChart-spec.tsx | 2 +- .../__snapshots__/CalendarChart-spec.tsx.snap | 6 + .../DensityHeatmapChart-spec.tsx.snap | 6 + .../__snapshots__/HeatmapChart-spec.tsx.snap | 6 + .../__snapshots__/LiquidChart-spec.tsx.snap | 4 +- 21 files changed, 1152 insertions(+), 18 deletions(-) create mode 100644 unittest/components/Chart-data-update-spec.tsx create mode 100644 unittest/components/Facet-spec.tsx create mode 100644 unittest/components/react-tooltip-spec.tsx diff --git a/demos/funnel/basicFunnel.jsx b/demos/funnel/basicFunnel.jsx index c846a7f6..13b7df92 100644 --- a/demos/funnel/basicFunnel.jsx +++ b/demos/funnel/basicFunnel.jsx @@ -34,7 +34,7 @@ function Demo() { height={600} data={dv.rows} padding={[20, 120, 95]} - forceFit + autoFit > + , React.Props { function Facet(props: IFacetProps) { const chart = useChartView(); + const chartInstance = useChartInstance(); const { type, children, ...cfg } = props; // @ts-ignore if (chart.facetInstance) { @@ -46,6 +48,8 @@ function Facet(props: IFacetProps) { chart.facetInstance.destroy(); // @ts-ignore chart.facetInstance = null; + // todo: 是否有必要区分数据更新和配置项更新,当前处理为全部都重绘 + chartInstance.forceReRender = true; // 重新渲染,不能更新 } if (_isFunction(children)) { chart.facet(type, { diff --git a/src/core.ts b/src/core.ts index 22f22a0b..50510b4d 100644 --- a/src/core.ts +++ b/src/core.ts @@ -17,7 +17,7 @@ registerEngine('svg', SVGEngine); // @ts-ignore export * from '@antv/g2/lib/core'; -export const VERSION = '4.1.10-beta.2'; +export const VERSION = '4.1.10'; diff --git a/unittest/components/Chart-data-update-spec.tsx b/unittest/components/Chart-data-update-spec.tsx new file mode 100644 index 00000000..0d78d4fe --- /dev/null +++ b/unittest/components/Chart-data-update-spec.tsx @@ -0,0 +1,300 @@ +import React, { useEffect, useState } from 'react'; +import Chart from '../../src/components/Chart'; +import Tooltip from '../../src/components/Tooltip'; +import LineAdvance from '../../src/geometry/LineAdvance'; +import '../../src/core'; +import { render, act } from '@testing-library/react'; + +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +const MOCK_DATA = [ + { + month: "Jan", + city: "Tokyo", + temperature: 7 + }, + { + month: "Jan", + city: "London", + temperature: 3.9 + }, + { + month: "Feb", + city: "Tokyo", + temperature: 13 + }, + { + month: "Feb", + city: "London", + temperature: 4.2 + }, + { + month: "Mar", + city: "Tokyo", + temperature: 16.5 + }, + { + month: "Mar", + city: "London", + temperature: 5.7 + }, + { + month: "Apr", + city: "Tokyo", + temperature: 14.5 + }, + { + month: "Apr", + city: "London", + temperature: 8.5 + }, + { + month: "May", + city: "Tokyo", + temperature: 10 + }, + { + month: "May", + city: "London", + temperature: 11.9 + }, + { + month: "Jun", + city: "Tokyo", + temperature: 7.5 + }, + { + month: "Jun", + city: "London", + temperature: 15.2 + }, + { + month: "Jul", + city: "Tokyo", + temperature: 9.2 + }, + { + month: "Jul", + city: "London", + temperature: 17 + }, + { + month: "Aug", + city: "Tokyo", + temperature: 14.5 + }, + { + month: "Aug", + city: "London", + temperature: 16.6 + }, + { + month: "Sep", + city: "Tokyo", + temperature: 9.3 + }, + { + month: "Sep", + city: "London", + temperature: 14.2 + }, + { + month: "Oct", + city: "Tokyo", + temperature: 8.3 + }, + { + month: "Oct", + city: "London", + temperature: 10.3 + }, + { + month: "Nov", + city: "Tokyo", + temperature: 8.9 + }, + { + month: "Nov", + city: "London", + temperature: 5.6 + }, + { + month: "Dec", + city: "Tokyo", + temperature: 5.6 + }, + { + month: "Dec", + city: "London", + temperature: 9.8 + } +]; + + +const MOCK_DATA2 = [ + { + month: "Jan", + city: "Tokyo", + temperature: 7 + }, + { + month: "Jan", + city: "London", + temperature: 3.9 + }, + { + month: "Feb", + city: "Tokyo", + temperature: 13 + }, + { + month: "Feb", + city: "London", + temperature: 4.2 + }, + { + month: "Mar", + city: "Tokyo", + temperature: 16.5 + }, + { + month: "Mar", + city: "London", + temperature: 5.7 + }, + { + month: "Apr", + city: "Tokyo", + temperature: 14.5 + }, + { + month: "Apr", + city: "London", + temperature: 8.5 + }, + { + month: "May", + city: "Tokyo", + temperature: 10 + }, + { + month: "May", + city: "London", + temperature: 11.9 + }, + { + month: "Jun", + city: "Tokyo", + temperature: 7.5 + }, + { + month: "Jun", + city: "London", + temperature: 15.2 + }, + { + month: "Jul", + city: "Tokyo", + temperature: 9.2 + }, + { + month: "Jul", + city: "London", + temperature: 17 + }, + { + month: "Aug", + city: "Tokyo", + temperature: 14.5 + }, + { + month: "Aug", + city: "London", + temperature: 16.6 + }, + { + month: "Sep", + city: "Tokyo", + temperature: 9.3 + }, + { + month: "Sep", + city: "London", + temperature: 14.2 + }, + { + month: "Oct", + city: "Tokyo", + temperature: 8.3 + }, + { + month: "Oct", + city: "London", + temperature: 10.3 + }, + { + month: "Nov", + city: "Tokyo", + temperature: 3.9 + }, + { + month: "Nov", + city: "London", + temperature: 5.6 + }, + { + month: "Dec", + city: "Tokyo", + temperature: 3.6 + }, + { + month: "Dec", + city: "London", + temperature: 1.8 + } +]; + +const Demo = (props) => { + const [data, setData] = useState([{ + month: "Dec", + city: "London", + temperature: 9.8 + }]); + + const [loading, setLoading] = useState(false); + + return
+
{ + setLoading(true); + setData(MOCK_DATA2); + setTimeout(() => { + setData(MOCK_DATA); + setLoading(false); + }, 1000) + }}>click me
+ {`${loading}`} + + + +
+} + + +describe('components-Chart', () => { + + test('数据不变则不更新图表', async () => { + let chart = null; + render( chart = c} />); + expect(chart.options.data.length).toBe(1); + // await sleep(1000); + // expect(chart.options.data.length).toBe(MOCK_DATA.length); + }) +}) diff --git a/unittest/components/Chart-spec.tsx b/unittest/components/Chart-spec.tsx index 9258db57..c2a620c2 100644 --- a/unittest/components/Chart-spec.tsx +++ b/unittest/components/Chart-spec.tsx @@ -42,7 +42,7 @@ describe('components-Chart', () => { expect(chart.options.data.length).toBe(507); }) - test('数据不变则不更新图表', async () => { + test('异步数据更新图表', async () => { let chart = null; render( chart = c} />); await sleep(1000); diff --git a/unittest/components/Facet-spec.tsx b/unittest/components/Facet-spec.tsx new file mode 100644 index 00000000..2ac7c29b --- /dev/null +++ b/unittest/components/Facet-spec.tsx @@ -0,0 +1,616 @@ +import React, { useEffect, useState } from 'react'; +import { Chart, Tooltip, Legend, Facet, getTheme } from "../../src"; +import '../../src/core'; +import { render, act } from '@testing-library/react'; + +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +function FacetSuccessRate({ indexNameColorMap, typeNameMap, onGetG2Instance }) { + const [data, setData] = useState(myData); + useEffect(() => { + () => setData(myData.slice(0,30)); + // setTimeout(() => { + // act(() => setData(myData.slice(0,30))); + // }, 1500) + }, []) + return ( +
+
{ + setData(myData.slice(0,30)); + }}>click me
+ + { + console.log(text, item); + return typeNameMap[text]; + } + }} /> + + { + return indexNameColorMap[val].title; + }, + }} + eachView={(view, facet) => { + view.coordinate().transpose(); + + if (facet.columnIndex === 0) { + view.axis("timeDate", { + tickLine: null, + line: null, + }); + view.axis("value", false); + } else { + view.axis(false); + } + + const color = indexNameColorMap[facet.columnValue].color; + view + .interval() + .adjust("stack") + .position("timeDate*value") + .color("type", [color, "#ebedf0"]) + .size(20) + .label("value*type", (value, type) => { + if (type === "remain") { + return null; + } + const offset = value < 30 ? 10 : -4; + return { + content: `${value}%`, + offset, + }; + }) + .tooltip( + "timeDate*value*indexCode*type", + (timeDate, value, indexCode, type) => { + return { + title: `日期:${timeDate}`, + value: `${type} : ${value}%`, + name: indexCode, + }; + } + ); + view.interaction("element-active"); + }} + /> + +
+ ); +} + + +const chartTheme = getTheme().colors10; +const myIndexNameColorMap = { + reg_suc_rate: { + title: "注册成功率", + color: chartTheme[0], + }, + reg_intention_rate: { + title: "注册意愿率", + color: chartTheme[1], + }, + login_suc_rate: { + title: "登录成功率", + color: chartTheme[2], + }, + login_intention_rate: { + title: "登录意愿率", + color: chartTheme[3], + }, +}; + +const myTypeNameMap = { + done: '已实现', + remain: '待提升空间' +} + +const myData = [ + { + indexCode: "reg_suc_rate", + timeDate: "20210101", + type: "done", + value: 10.8, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210101", + type: "remain", + value: 89.2, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210102", + type: "done", + value: 72.9, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210102", + type: "remain", + value: 27.1, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210103", + type: "done", + value: 2.8, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210103", + type: "remain", + value: 97.2, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210104", + type: "done", + value: 49.1, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210104", + type: "remain", + value: 50.9, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210105", + type: "done", + value: 11.6, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210105", + type: "remain", + value: 88.4, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210106", + type: "done", + value: 23.8, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210106", + type: "remain", + value: 76.2, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210107", + type: "done", + value: 2.9, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210107", + type: "remain", + value: 97.1, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210108", + type: "done", + value: 2.7, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210108", + type: "remain", + value: 97.3, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210109", + type: "done", + value: 3.6, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210109", + type: "remain", + value: 96.4, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210110", + type: "done", + value: 1.3, + }, + { + indexCode: "reg_suc_rate", + timeDate: "20210110", + type: "remain", + value: 98.7, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210101", + type: "done", + value: 175.4, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210101", + type: "remain", + value: 24.6, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210102", + type: "done", + value: 165.2, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210102", + type: "remain", + value: 34.8, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210103", + type: "done", + value: 108.4, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210103", + type: "remain", + value: 91.6, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210104", + type: "done", + value: 73.2, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210104", + type: "remain", + value: 126.8, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210105", + type: "done", + value: 46.9, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210105", + type: "remain", + value: 153.1, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210106", + type: "done", + value: 38.6, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210106", + type: "remain", + value: 161.4, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210107", + type: "done", + value: 22, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210107", + type: "remain", + value: 178, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210108", + type: "done", + value: 12.1, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210108", + type: "remain", + value: 187.9, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210109", + type: "done", + value: 5.5, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210109", + type: "remain", + value: 194.5, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210110", + type: "done", + value: 1.8, + }, + { + indexCode: "login_suc_rate", + timeDate: "20210110", + type: "remain", + value: 198.2, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210101", + type: "done", + value: 6.2, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210101", + type: "remain", + value: 93.8, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210102", + type: "done", + value: 44.1, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210102", + type: "remain", + value: 55.9, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210103", + type: "done", + value: 2.6, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210103", + type: "remain", + value: 97.4, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210104", + type: "done", + value: 67, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210104", + type: "remain", + value: 33, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210105", + type: "done", + value: 24.7, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210105", + type: "remain", + value: 75.3, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210106", + type: "done", + value: 61.6, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210106", + type: "remain", + value: 38.4, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210107", + type: "done", + value: 13.2, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210107", + type: "remain", + value: 86.8, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210108", + type: "done", + value: 22.4, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210108", + type: "remain", + value: 77.6, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210109", + type: "done", + value: 65.7, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210109", + type: "remain", + value: 34.3, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210110", + type: "done", + value: 73, + }, + { + indexCode: "login_intention_rate", + timeDate: "20210110", + type: "remain", + value: 27, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210101", + type: "done", + value: 6.2, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210101", + type: "remain", + value: 93.8, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210102", + type: "done", + value: 44.1, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210102", + type: "remain", + value: 55.9, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210103", + type: "done", + value: 2.6, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210103", + type: "remain", + value: 97.4, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210104", + type: "done", + value: 67, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210104", + type: "remain", + value: 33, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210105", + type: "done", + value: 24.7, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210105", + type: "remain", + value: 75.3, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210106", + type: "done", + value: 61.6, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210106", + type: "remain", + value: 38.4, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210107", + type: "done", + value: 13.2, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210107", + type: "remain", + value: 86.8, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210108", + type: "done", + value: 22.4, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210108", + type: "remain", + value: 77.6, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210109", + type: "done", + value: 65.7, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210109", + type: "remain", + value: 34.3, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210110", + type: "done", + value: 73, + }, + { + indexCode: "reg_intention_rate", + timeDate: "20210110", + type: "remain", + value: 27, + }, +]; + +describe('components-Chart', () => { + + test('数据不变则不更新图表', async () => { + let chart = null; + render( chart = c} />); + + }) +}) diff --git a/unittest/components/react-tooltip-spec.tsx b/unittest/components/react-tooltip-spec.tsx new file mode 100644 index 00000000..7d73e1dd --- /dev/null +++ b/unittest/components/react-tooltip-spec.tsx @@ -0,0 +1,192 @@ +import React, { useEffect, useState } from 'react'; +import { + Chart, + Tooltip, + Interval, + Axis, + Legend +} from "../../src"; +import '../../src/core'; +import { render, act } from '@testing-library/react'; + +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +// 数据源 +const data1 = [ + { + "type": "核心Topic", + "dept": "dept1", + "count": 10 + }, + { + "type": "跨团队Topic", + "dept": "dept1", + "count": 0 + }, + { + "type": "内部Topic", + "dept": "dept1", + "count": 0 + }, + { + "type": "核心Topic", + "dept": "dept2", + "count": 3 + }, + { + "type": "跨团队Topic", + "dept": "dept2", + "count": 2 + }, + { + "type": "内部Topic", + "dept": "dept2", + "count": 5 + } +]; + +const data2=[ + { + "type": "核心Topic", + "dept": "dept3", + "count": 3 + }, + { + "type": "跨团队Topic", + "dept": "dept3", + "count": 2 + }, + { + "type": "内部Topic", + "dept": "dept3", + "count": 4 + }, + { + "type": "核心Topic", + "dept": "dept4", + "isLeader": true, + "workNo": "165666", + "count": 3 + }, + { + "type": "跨团队Topic", + "dept": "dept4", + "count": 0 + }, + { + "type": "内部Topic", + "dept": "dept4", + "count": 5 + }] + + +class Demo extends React.Component { +constructor(props) { + super(props) + this.state = { data: data1 } +} +render() { + const { data } = this.state; + const summary = data.reduce((pre , cur) => { + const { dept, count, type } = cur; + let item = pre.find((p) => p.key === dept); + if (!item) { + item = { key: dept, value: count }; + pre.push(item); + } else item.value += count; + item[type] = count + return pre; + }, []); + // 排序 + summary.sort((s1, s2) => { + let v=s2.value - s1.value + if(v===0) { + v=s2["核心Topic"] - s1["核心Topic"] + } + if(v===0) { + v=s2["跨团队Topic"] - s1["跨团队Topic"] + } + if(v===0) { + v=s2["内部Topic"] - s1["内部Topic"] + } + return v + }); + + // 设置X轴刻度值 + const scale = { + dept: { + values: summary.map((s) => s.key), + }, + }; + return ( +
+ {this.setState({data:data2})}}>加载data2 + + { + if (type === "核心Topic") { + return '#ff9328'; + } + if (type === "跨团队Topic") { + return '#0384fd'; + } + if (type === "内部Topic") { + return '#05bfa5'; + } + return 'blue'; + }]} + position="dept*count" + /> + + + {(title,items) => { + console.log(title) + let content=[] + let sum = 0 + items?.map((v, i) => { + + content.push(
  • + + {v.name}: + {v.value} +
  • ) + sum+=parseInt(v.value) + }) + content.unshift(
  • + + 总计: + {sum} +
  • ) + + // items 是个数组,即被触发tooltip的数据。 + // 获取items的颜色 + console.log(content) + return (
    +
    {title}
    +
      {content}
    +
    ) + }} +
    +
    +
    ) +} + +} + +describe('components-Chart', () => { + + test('数据不变则不更新图表', async () => { + let chart = null; + render( chart = c} />); + + }) +}) diff --git a/unittest/plots-base/BasePlot-spec.tsx b/unittest/plots-base/BasePlot-spec.tsx index 302c306c..5aa16173 100644 --- a/unittest/plots-base/BasePlot-spec.tsx +++ b/unittest/plots-base/BasePlot-spec.tsx @@ -166,7 +166,7 @@ describe('基础功能-以AreaChart为demo', () => { }) fireEvent(canvas.get('el'), new MouseEvent('mouseup', getClientPoint(plot.chart.canvas, 130,100))); fireEvent.click(screen.getByText(/图表标题/i)); - // .toHaveBeenCalledTimes(1); 待g2Plot修复 [已修复] + expect(handleClick).toHaveBeenCalledTimes(1); // 图表标题是独立的div expect(handletTitleClick).toHaveBeenCalledTimes(1); diff --git a/unittest/plots/CalendarChart-spec.tsx b/unittest/plots/CalendarChart-spec.tsx index 3850f3a8..e3d49620 100644 --- a/unittest/plots/CalendarChart-spec.tsx +++ b/unittest/plots/CalendarChart-spec.tsx @@ -224,7 +224,7 @@ describe('Plots-CalendarChart', () => { } />) expect(chart.options).toMatchSnapshot(); - cleanup(); + // cleanup(); }); test('新版日历图', () => { let chart = null; @@ -252,6 +252,6 @@ describe('Plots-CalendarChart', () => { } />) expect(chart.options).toMatchSnapshot(); - cleanup(); + // cleanup(); }); }) diff --git a/unittest/plots/HeatmapChart-spec.tsx b/unittest/plots/HeatmapChart-spec.tsx index e7575eb4..a7ba9a7a 100644 --- a/unittest/plots/HeatmapChart-spec.tsx +++ b/unittest/plots/HeatmapChart-spec.tsx @@ -139,7 +139,7 @@ describe('Plots-HeatmapChart', () => { data={MOCK_DATA} title={{ visible: true, - text: '热力图形状大小映射', + text: '新版热力图基础用法', }} xField='name' yField='country' diff --git a/unittest/plots/PieChart-spec.tsx b/unittest/plots/PieChart-spec.tsx index 27282462..f6244795 100644 --- a/unittest/plots/PieChart-spec.tsx +++ b/unittest/plots/PieChart-spec.tsx @@ -178,6 +178,6 @@ describe('Plots-PieChart', () => { } />); expect(chart.options).toMatchSnapshot(); - // cleanup(); + cleanup(); }); }); diff --git a/unittest/plots/RingProgressChart-spec.tsx b/unittest/plots/RingProgressChart-spec.tsx index 4456d72f..3c97f848 100644 --- a/unittest/plots/RingProgressChart-spec.tsx +++ b/unittest/plots/RingProgressChart-spec.tsx @@ -16,6 +16,6 @@ describe('Plots-RingProgressChart', () => { } />) expect(chart.options).toMatchSnapshot(); - // cleanup(); + cleanup(); }) }) diff --git a/unittest/plots/WordCloudChart-spec.tsx b/unittest/plots/WordCloudChart-spec.tsx index 05c054a4..7a1b0200 100644 --- a/unittest/plots/WordCloudChart-spec.tsx +++ b/unittest/plots/WordCloudChart-spec.tsx @@ -463,6 +463,6 @@ describe('Plots-WordCloudChart', () => { ); expect(chart.options.tooltip).toBe(false); expect(chart.options.random).toBe(false); - // cleanup(); + cleanup(); }); }); diff --git a/unittest/plots/__snapshots__/CalendarChart-spec.tsx.snap b/unittest/plots/__snapshots__/CalendarChart-spec.tsx.snap index 3da388d4..37d9c382 100644 --- a/unittest/plots/__snapshots__/CalendarChart-spec.tsx.snap +++ b/unittest/plots/__snapshots__/CalendarChart-spec.tsx.snap @@ -13,6 +13,9 @@ Object { "color": "#BAE7FF-#1890FF-#0050B3", "colorField": "commits", "colors": "#BAE7FF-#1890FF-#0050B3", + "coordinate": Object { + "type": "rect", + }, "data": Array [ Object { "commits": 1, @@ -1423,6 +1426,9 @@ Object { "autoFit": true, "color": "#BAE7FF-#1890FF-#0050B3", "colorField": "commits", + "coordinate": Object { + "type": "rect", + }, "data": Array [ Object { "commits": 1, diff --git a/unittest/plots/__snapshots__/DensityHeatmapChart-spec.tsx.snap b/unittest/plots/__snapshots__/DensityHeatmapChart-spec.tsx.snap index 73414dfd..48d30a0b 100644 --- a/unittest/plots/__snapshots__/DensityHeatmapChart-spec.tsx.snap +++ b/unittest/plots/__snapshots__/DensityHeatmapChart-spec.tsx.snap @@ -12,6 +12,9 @@ Object { "autoFit": true, "color": "#F51D27-#FA541C-#FF8C12-#FFC838-#FAFFA8-#80FF73-#12CCCC-#1890FF-#6E32C2", "colorField": "tmp", + "coordinate": Object { + "type": "rect", + }, "data": Array [], "legend": false, "padding": "auto", @@ -86,6 +89,9 @@ Object { "#bc448c", ], "colorField": "tmp", + "coordinate": Object { + "type": "rect", + }, "data": Array [], "legend": false, "padding": "auto", diff --git a/unittest/plots/__snapshots__/HeatmapChart-spec.tsx.snap b/unittest/plots/__snapshots__/HeatmapChart-spec.tsx.snap index 642d3246..2bfde92e 100644 --- a/unittest/plots/__snapshots__/HeatmapChart-spec.tsx.snap +++ b/unittest/plots/__snapshots__/HeatmapChart-spec.tsx.snap @@ -18,6 +18,9 @@ Object { "#114d90", ], "colorField": "value", + "coordinate": Object { + "type": "rect", + }, "data": Array [ Object { "country": "AD", @@ -591,6 +594,9 @@ Object { "#114d90", ], "colorField": "value", + "coordinate": Object { + "type": "rect", + }, "data": Array [ Object { "country": "AD", diff --git a/unittest/plots/__snapshots__/LiquidChart-spec.tsx.snap b/unittest/plots/__snapshots__/LiquidChart-spec.tsx.snap index 39c5efa4..165a1a5b 100644 --- a/unittest/plots/__snapshots__/LiquidChart-spec.tsx.snap +++ b/unittest/plots/__snapshots__/LiquidChart-spec.tsx.snap @@ -9,7 +9,6 @@ Object { 10, ], "autoFit": true, - "color": "#6a99f9", "data": 0.5639, "outline": Object { "border": 2, @@ -17,6 +16,7 @@ Object { }, "percent": 0.5639, "radius": 0.9, + "shape": "circle", "statistic": Object { "content": Object { "formatter": [Function], @@ -45,7 +45,6 @@ Object { 10, ], "autoFit": true, - "color": "#6a99f9", "data": 0.5, "outline": Object { "border": 4, @@ -53,6 +52,7 @@ Object { }, "percent": 0.5, "radius": 0.9, + "shape": "circle", "statistic": Object { "content": Object { "formatter": [Function],