Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/components/ECharts/MultiSeriesChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import { useDarkModeManager } from '~/contexts/LocalStorage'
import { useDefaults } from '../useDefaults'
import { mergeDeep } from '../utils'

function LegendButton({ text, onClick }) {
return (
<button
className="pro-border hover:pro-bg1 hover:pro-text1 pro-hover-bg flex items-center gap-2 rounded-md border px-2 py-1 text-xs text-(--text-secondary) transition-colors hover:bg-(--link-hover-bg) disabled:cursor-not-allowed disabled:opacity-50"
onClick={onClick}
>
{text}
</button>
)
}

interface IMultiSeriesChartProps {
series?: Array<{
data: Array<[number, number]>
Expand Down Expand Up @@ -263,6 +274,17 @@ export default function MultiSeriesChart({

return (
<div className="relative">
<div className="flex items-center justify-start gap-2 px-1 pb-1 md:px-3 md:pb-3">
<LegendButton text="All" onClick={() => chartRef.current.dispatchAction({ type: 'legendAllSelect' })} />
<LegendButton
text="None"
onClick={() =>
processedSeries.forEach((serie) =>
chartRef.current.dispatchAction({ type: 'legendUnSelect', name: serie.name })
)
}
/>
</div>
<div id={id} className="my-auto min-h-[360px]" style={height ? { height } : undefined}></div>
</div>
)
Expand Down