Skip to content

Commit e6218d2

Browse files
invisalgeoquant
andauthored
feat(kumo): add Chart component with ECharts integration (#93)
* feat(kumo): add Chart component with ECharts integration - Add Chart, ChartPalette, and TimeseriesChart components - Integrate Apache ECharts for data visualization - Add accessibility improvements to Button examples (aria-labels) - Update component registry with new Chart component - Add demo and documentation pages * docs: reorganize chart documentation into dedicated charts section - Add Charts navigation section to sidebar with collapsible menu - Split chart examples into dedicated pages (timeseries, custom) - Create charts landing page with setup instructions and navigation - Move chart.astro to charts/custom.astro for better organization - Remove debug code block from ChartDemo component * docs: add comprehensive timeseries chart examples - Add BasicLineChartDemo showing simple time-based data - Add IncompleteDataChartDemo demonstrating incomplete data regions - Add TimeRangeSelectionChartDemo with interactive time range selection - Expand timeseries page with multiple examples and usage patterns - Include code examples for each chart variant * refactor(kumo): split timeseriess to separate file * refactor(docs): add small demo for chart docs index * feat(docs): improve the chart color palette docs * feat(kumo): add chart legend * feat(chart): add legend inactive state * refactor(chart): extract Color.ts, add chart package export entry * refactor(chart): rename yAxisTickNumber to yAxisTickCount, convert ChartPalette to namespace, add JSDoc, export types * feat(chart): add yAxisTickLabelFormat prop and xAxisTickCount wiring Adds a yAxisTickLabelFormat callback to TimeseriesChart for custom y-axis tick label formatting, wires xAxisTickCount to the x-axis splitNumber, applies the formatter in tooltips, and adds a CustomXAxisLabelFormat demo with docs. * feat(chart): add gradient prop to TimeseriesChart with docs example * feat(chart): add loading state with animated sine-wave skeleton to TimeseriesChart * chore: add changeset for TimeseriesChart component * refactor(chart): remove unused cn import from TimeseriesChart --------- Co-authored-by: geoquant <1237781+geoquant@users.noreply.github.com>
1 parent 3170d65 commit e6218d2

File tree

19 files changed

+2270
-12
lines changed

19 files changed

+2270
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/kumo": minor
3+
---
4+
5+
Add TimeseriesChart component with ECharts integration, supporting legends, gradient fills, custom axis formatting, loading skeleton state, and configurable color palettes.

packages/kumo-docs-astro/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@phosphor-icons/react": "catalog:",
2424
"astro": "^5.16.7",
2525
"clsx": "catalog:",
26+
"echarts": "^6.0.0",
2627
"match-sorter": "^8.2.0",
2728
"react-markdown": "10.1.0",
2829
"remark-gfm": "4.0.1",

packages/kumo-docs-astro/src/components/SidebarNav.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ const componentItems: NavItem[] = [
7272
{ label: "Tooltip", href: "/components/tooltip" },
7373
];
7474

75+
const chartItems: NavItem[] = [
76+
{ label: "Charts", href: "/charts" },
77+
{ label: "Timeseries", href: "/charts/timeseries" },
78+
{ label: "Custom Chart", href: "/charts/custom" },
79+
];
80+
7581
// Blocks are CLI-installed components that you own and can customize
7682
// Use `npx @cloudflare/kumo blocks` to see available blocks
7783
// Use `npx @cloudflare/kumo add <block>` to install
@@ -98,6 +104,7 @@ export function SidebarNav({ currentPath }: SidebarNavProps) {
98104
const [sidebarOpen, setSidebarOpen] = useState(true);
99105
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
100106
const [componentsOpen, setComponentsOpen] = useState(true);
107+
const [chartsOpen, setChartsOpen] = useState(true);
101108
const [blocksOpen, setBlocksOpen] = useState(true);
102109

103110
const activePath = normalizePathname(currentPath);
@@ -242,6 +249,44 @@ export function SidebarNav({ currentPath }: SidebarNavProps) {
242249
</ul>
243250
</div>
244251

252+
<div className="mb-4">
253+
<button
254+
type="button"
255+
className="flex w-full cursor-pointer items-center justify-between rounded-lg px-2 py-2 text-sm font-medium text-kumo-default transition-colors hover:bg-kumo-tint"
256+
onClick={() => setChartsOpen(!chartsOpen)}
257+
>
258+
<span>Charts</span>
259+
<CaretDownIcon
260+
size={12}
261+
className={cn(
262+
"text-kumo-subtle transition-transform duration-200",
263+
!chartsOpen && "-rotate-90",
264+
)}
265+
/>
266+
</button>
267+
<ul
268+
className={cn(
269+
"flex flex-col gap-px overflow-hidden transition-all duration-300 ease-in-out mt-1",
270+
chartsOpen ? "max-h-[500px] opacity-100" : "max-h-0 opacity-0",
271+
)}
272+
>
273+
{chartItems.map((item) => (
274+
<li key={item.href}>
275+
<a
276+
href={item.href}
277+
className={cn(
278+
LI_STYLE,
279+
"pl-4",
280+
currentPath === item.href && LI_ACTIVE_STYLE,
281+
)}
282+
>
283+
{item.label}
284+
</a>
285+
</li>
286+
))}
287+
</ul>
288+
</div>
289+
245290
<div>
246291
{/* Blocks Section */}
247292
<button
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
interface Props {
3+
title: string;
4+
description: string;
5+
href: string;
6+
}
7+
8+
const { title, description, href } = Astro.props;
9+
---
10+
11+
<div class="rounded-lg border border-kumo-line bg-kumo-elevated">
12+
<div class="p-4">
13+
<div class="text-kumo-default">{title}</div>
14+
<div class="mt-1 text-sm text-kumo-secondary">{description}</div>
15+
16+
<div class="mt-4">
17+
<a
18+
href={href}
19+
class="inline-flex items-center justify-center rounded-md border border-kumo-line bg-kumo-control px-3 py-1.5 text-sm font-medium text-kumo-default transition-colors hover:bg-kumo-recessed"
20+
>
21+
Learn more
22+
</a>
23+
</div>
24+
</div>
25+
26+
<div class="border-kumo-line border-t bg-kumo-base p-2">
27+
<slot />
28+
</div>
29+
</div>

0 commit comments

Comments
 (0)