diff --git a/frontend/packages/core/builder/mock.js b/frontend/packages/core/builder/mock.js index 39e5c0ef988f9b51072e9cfda6d7c5c0540813ff..9a5ef38ab6991959f8da98a7710fc5c5638c1332 100644 --- a/frontend/packages/core/builder/mock.js +++ b/frontend/packages/core/builder/mock.js @@ -1,8 +1,11 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const {middleware} = require('@visualdl/mock'); +const {createProxyMiddleware} = require('http-proxy-middleware'); module.exports = { - middleware, + middleware: process.env.MOCK + ? () => createProxyMiddleware({target: process.env.MOCK, changeOrigin: true}) + : middleware, pathname: '/api' }; diff --git a/frontend/packages/core/package.json b/frontend/packages/core/package.json index 14b137da368a84281b3c8d65a24c784624560a7e..31c183a341c503d9b0462b7aa8341ed67f0903e8 100644 --- a/frontend/packages/core/package.json +++ b/frontend/packages/core/package.json @@ -96,6 +96,7 @@ "enhanced-resolve": "4.3.0", "express": "4.17.1", "fs-extra": "9.0.1", + "http-proxy-middleware": "1.0.5", "jest": "26.4.2", "snowpack": "2.10.1", "typescript": "4.0.2", diff --git a/frontend/packages/core/src/components/StackChart.tsx b/frontend/packages/core/src/components/StackChart.tsx index 4e755d7531d62621935d88f2432e1e06ccf048e9..58032e3b7b84150756d5fad7469cad926d4556fd 100644 --- a/frontend/packages/core/src/components/StackChart.tsx +++ b/frontend/packages/core/src/components/StackChart.tsx @@ -64,7 +64,7 @@ const StackChart = React.forwardRef }; const rawData = useMemo(() => seriesData.data ?? [], [seriesData.data]); - const negativeY = useMemo(() => minY - (maxY - minY) * 0.4, [minY, maxY]); + const negativeY = useMemo(() => (minY === 0 && maxY === 0 ? -0.4 : minY - (maxY - minY) * 0.4), [minY, maxY]); const getPoint = useCallback( (x: number, y: number, z: number, getCoord: GetCoord) => {