-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: laixingyou <[email protected]>
- Loading branch information
1 parent
a95c27b
commit 9f6049a
Showing
37 changed files
with
1,757 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { useRef, useEffect, useCallback } from 'react'; | ||
import { useDeepCompareEffect } from 'ahooks'; | ||
import { init, getInstanceByDom } from 'echarts'; | ||
import type { CSSProperties } from 'react'; | ||
import type { EChartsOption, ECharts, SetOptionOpts } from 'echarts'; | ||
import { useResizeDetector } from 'react-resize-detector'; | ||
import useInViewportDebounce from '@common/hooks/useInViewportDebounce'; | ||
import * as echarts from 'echarts/core'; | ||
import { CanvasRenderer } from 'echarts/renderers'; | ||
import { Bar3DChart } from 'echarts-gl/charts'; | ||
import { Grid3DComponent } from 'echarts-gl/components'; | ||
|
||
echarts.use([Grid3DComponent, Bar3DChart, CanvasRenderer]); | ||
export interface ReactEChartsProps { | ||
option: EChartsOption; | ||
style?: CSSProperties; | ||
settings?: SetOptionOpts; | ||
loading?: boolean; | ||
theme?: 'light' | 'dark'; | ||
containerRef?: React.RefObject<HTMLElement>; | ||
_tracing?: string; | ||
} | ||
|
||
const EChartX: React.FC<ReactEChartsProps> = ({ | ||
option, | ||
style, | ||
settings = { notMerge: true }, | ||
loading, | ||
theme, | ||
containerRef, | ||
}) => { | ||
const inView = useInViewportDebounce(containerRef); | ||
const chartRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
// init | ||
let chart: ECharts | undefined; | ||
if (chartRef.current !== null) { | ||
chart = init(chartRef.current, theme); | ||
} | ||
return () => { | ||
chart?.dispose(); | ||
}; | ||
}, [theme]); | ||
|
||
useDeepCompareEffect(() => { | ||
// Update chart | ||
if (inView && chartRef.current !== null) { | ||
const chart = getInstanceByDom(chartRef.current)!; | ||
chart.setOption(option, settings); | ||
} | ||
}, [option, settings, inView]); | ||
|
||
useEffect(() => { | ||
// Update chart | ||
if (chartRef.current !== null) { | ||
const chart = getInstanceByDom(chartRef.current)!; | ||
if (inView) { | ||
loading === true ? chart?.showLoading() : chart?.hideLoading(); | ||
} else { | ||
} | ||
} | ||
}, [loading, inView]); | ||
|
||
// ----------------container resize------------------------------ | ||
const onResize = useCallback((width?: number, height?: number) => { | ||
if (chartRef.current !== null) { | ||
const chart = getInstanceByDom(chartRef.current)!; | ||
chart?.resize({ | ||
width: 'auto', | ||
height: Number(height) > 650 ? 650 : 280, | ||
}); | ||
} | ||
}, []); | ||
|
||
useResizeDetector({ | ||
targetRef: containerRef, | ||
onResize, | ||
skipOnMount: true, | ||
}); | ||
|
||
return ( | ||
<div ref={chartRef} style={{ width: '100%', height: '100%', ...style }} /> | ||
); | ||
}; | ||
|
||
export default React.memo(EChartX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,133 @@ | ||
export const gradientRamp = [ | ||
[ | ||
'#4a90e2', | ||
'#1d2c4e', | ||
'#29467f', | ||
'#2d51a0', | ||
'#5470c6', | ||
'#3063c5', | ||
'#3978d7', | ||
'#70b1ea', | ||
'#9ecdf2', | ||
'#c6e0f7', | ||
'#4a90e2', | ||
'#3063c5', | ||
'#3978d7', | ||
'#70b1ea', | ||
'#9ecdf2', | ||
'#c6e0f7', | ||
'#dfedfa', | ||
'#f1f7fd', | ||
], | ||
[ | ||
'#9858f4', | ||
'#320962', | ||
'#4e1e85', | ||
'#5e23a6', | ||
'#6d25cb', | ||
'#8136e7', | ||
'#9858f4', | ||
'#a872f9', | ||
'#d1b5fd', | ||
'#e5d6fe', | ||
'#f1e8ff', | ||
'#f9f5ff', | ||
// '#dfedfa', | ||
// '#f1f7fd', | ||
], | ||
[ | ||
'#91cc75', | ||
'#50961a', | ||
'#6bbc26', | ||
'#89d744', | ||
'#a7e56d', | ||
'#ccf1a5', | ||
'#6bbc26', | ||
'#142909', | ||
'#2f4e19', | ||
'#335c1a ', | ||
'#3f7219', | ||
'#50961a', | ||
'#6bbc26', | ||
'#89d744', | ||
'#a7e56d', | ||
'#ccf1a5', | ||
'#e5f8cf', | ||
'#f3fce9', | ||
], | ||
[ | ||
// '#e9b308', | ||
// '#a06207', | ||
'#fac858', | ||
'#cb8a03', | ||
'#e9b308', | ||
'#f9cc15', | ||
'#fce146', | ||
'#fff08a', | ||
'#cb8a03', | ||
'#e9b308', | ||
'#f9cc15', | ||
'#fce146', | ||
'#fff08a', | ||
'#fef9c4', | ||
], | ||
[ | ||
'#ee6666', | ||
'#b91b1c', | ||
'#dc2626', | ||
'#f87271', | ||
'#fca5a5', | ||
'#fecaca', | ||
'#ee4444', | ||
'#b91b1c', | ||
'#dc2626', | ||
'#f87271', | ||
'#fca5a5', | ||
'#fecaca', | ||
], | ||
[ | ||
'#f97316', | ||
'#431407', | ||
'#7c2d12', | ||
'#9a3412', | ||
'#c2410c', | ||
'#ea580c', | ||
'#fb923c', | ||
'#fdba74', | ||
'#fed7aa', | ||
'#f97316', | ||
'#c2410c', | ||
'#ea580c', | ||
'#fb923c', | ||
'#fdba74', | ||
'#fed7aa', | ||
'#ffedd5', | ||
'#fff7ed', | ||
], | ||
[ | ||
'#14b8a6', | ||
'#042f2e', | ||
'#134e4a', | ||
'#115e59', | ||
'#0f766e', | ||
'#0d9488', | ||
'#2dd4bf', | ||
'#5eead4', | ||
'#99f6e4', | ||
'#14b8a6', | ||
'#0f766e', | ||
'#0d9488', | ||
'#2dd4bf', | ||
'#5eead4', | ||
'#99f6e4', | ||
'#ccfbf1', | ||
'#f0fdfa', | ||
], | ||
[ | ||
'#9858f4', | ||
'#6d25cb', | ||
'#8136e7', | ||
'#a872f9', | ||
'#d1b5fd', | ||
'#e5d6fe', | ||
'#9858f4', | ||
'#6d25cb', | ||
'#8136e7', | ||
'#a872f9', | ||
'#d1b5fd', | ||
'#e5d6fe', | ||
], | ||
[ | ||
'#ec4899', | ||
'#500725', | ||
'#831843', | ||
'#9c164d', | ||
'#be185e', | ||
'#db2879', | ||
'#f472b5', | ||
'#f8a8d3', | ||
'#fccfea', | ||
'#ec4899', | ||
'#be185e', | ||
'#db2879', | ||
'#f472b5', | ||
'#f8a8d3', | ||
'#fccfea', | ||
'#fbe7f3', | ||
'#fcf2f8', | ||
], | ||
[ | ||
'#e9b308', | ||
'#432007', | ||
'#714013', | ||
'#844d0e', | ||
'#a06207', | ||
'#cb8a03', | ||
'#e9b308', | ||
'#f9cc15', | ||
'#fce146', | ||
'#fff08a', | ||
'#fef9c4', | ||
'#fefce8', | ||
], | ||
[ | ||
'#ee4444', | ||
'#450a0a', | ||
'#7f1d1c', | ||
'#9b1b1b', | ||
'#b91b1c', | ||
'#dc2626', | ||
'#ee4444', | ||
'#f87271', | ||
'#fca5a5', | ||
'#fecaca', | ||
'#fde2e2', | ||
'#fef2f2', | ||
], | ||
|
||
[ | ||
'#8c90a1', | ||
'#2f3135', | ||
'#52555d', | ||
'#626571', | ||
'#787a8c', | ||
'#a1a5b3', | ||
'#8c8fa2', | ||
'#b6b8c5', | ||
'#d2d6db', | ||
'#dfe3e6', | ||
'#edeff3', | ||
'#f5f7f9', | ||
'#8c90a1', | ||
'#787a8c', | ||
'#a1a5b3', | ||
'#b6b8c5', | ||
'#d2d6db', | ||
'#dfe3e6', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9f6049a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storybook – ./
storybook-git-main-compass-team.vercel.app
compass-web-2l68.vercel.app
storybook-compass-team.vercel.app
9f6049a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
compass-web – ./
compass-web-compass-team.vercel.app
compass-web-preview.vercel.app
compass-web-git-main-compass-team.vercel.app