-
Notifications
You must be signed in to change notification settings - Fork 18
[doc] Recharts guidelines added to documentation #2482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
45aae62
Adding recharts guidelines documentation
Jialecl 329747d
Changed examples to match codesandbox examples
Jialecl be19090
removed empty comment
Jialecl dc81dcc
Page structure changed & images added
Jialecl 6890925
Changed the structure into 2 groups and updated old documentation
Jialecl 6d0f6dd
Merge branch 'master' into jialecl/recharts-doc
PelayoFelgueroso 4298588
Small mistakes fixed in doc text
Jialecl 489d911
Merge branch 'jialecl/recharts-doc' of https://github.com/dxc-technol…
Jialecl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
25 changes: 25 additions & 0 deletions
25
apps/website/screens/guidelines/data-visualization/examples/rechartsAreaExample.tsx
This file contains hidden or 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,25 @@ | ||
| const code = `() => { | ||
| const data = [ | ||
| { name: "Mon", uv: 4000, pv: 2400 }, | ||
| { name: "Tue", uv: 3000, pv: 1398 }, | ||
| { name: "Wed", uv: 2000, pv: 9800 }, | ||
| { name: "Thu", uv: 2780, pv: 3908 }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <DxcInset space="var(--spacing-padding-l)"> | ||
| <AreaChart | ||
| data={data} | ||
| xKey="name" | ||
| areas={[ | ||
| { dataKey: "uv", name: "UV", color: "#5f249f" }, | ||
| { dataKey: "pv", name: "PV", color: "#0095ff", fillOpacity: 0.12 }, | ||
| ]} | ||
| layout={{ height: 300 }} | ||
| showLegend | ||
| /> | ||
| </DxcInset> | ||
| ); | ||
| };`; | ||
|
|
||
| export default { code, scope: {} }; |
26 changes: 26 additions & 0 deletions
26
apps/website/screens/guidelines/data-visualization/examples/rechartsBarExample.tsx
This file contains hidden or 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,26 @@ | ||
| const code = `() => { | ||
| const data = [ | ||
| { name: "Q1", revenue: 4200, costs: 2400 }, | ||
| { name: "Q2", revenue: 3000, costs: 1398 }, | ||
| { name: "Q3", revenue: 2000, costs: 9800 }, | ||
| { name: "Q4", revenue: 2780, costs: 3908 }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <DxcInset space="var(--spacing-padding-l)"> | ||
| <BarChart | ||
| data={data} | ||
| xKey="name" | ||
| bars={[ | ||
| { dataKey: "revenue", name: "Revenue", color: "#0095ff" }, | ||
| { dataKey: "costs", name: "Costs", color: "#5f249f" }, | ||
| ]} | ||
| axis={{ xLabel: "Quarter", yDomain: [0, 12000] }} | ||
| layout={{ height: 320, margin: { top: 16, right: 16, left: 8, bottom: 24 } }} | ||
| showLegend | ||
| /> | ||
| </DxcInset> | ||
| ); | ||
| };`; | ||
|
|
||
| export default { code, scope: {} }; |
15 changes: 15 additions & 0 deletions
15
apps/website/screens/guidelines/data-visualization/examples/rechartsHorizontalBarExample.tsx
This file contains hidden or 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,15 @@ | ||
| const code = `() => { | ||
| const data = [ | ||
| { label: "Performance", value: 82, fill: "#0095ff" }, | ||
| { label: "Reliability", value: 64, fill: "#5f249f" }, | ||
| { label: "Security", value: 91, fill: "#24a148" }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <DxcInset space="var(--spacing-padding-l)"> | ||
| <HorizontalBarChart data={data} styles={{ gap: "1.25rem", barHeight: 18 }} layout={{ width: "100%" }} /> | ||
| </DxcInset> | ||
| ); | ||
| };`; | ||
|
|
||
| export default { code, scope: {} }; |
27 changes: 27 additions & 0 deletions
27
apps/website/screens/guidelines/data-visualization/examples/rechartsLineExample.tsx
This file contains hidden or 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,27 @@ | ||
| const code = `() => { | ||
| const data = [ | ||
| { month: "Jan", desktop: 400, mobile: 240 }, | ||
| { month: "Feb", desktop: 300, mobile: 139 }, | ||
| { month: "Mar", desktop: 200, mobile: 980 }, | ||
| { month: "Apr", desktop: 278, mobile: 390 }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <DxcInset space="var(--spacing-padding-l)"> | ||
| <LineChart | ||
| data={data} | ||
| xKey="month" | ||
| lines={[ | ||
| { dataKey: "desktop", name: "Desktop", color: "#0095ff" }, | ||
| { dataKey: "mobile", name: "Mobile", color: "#5f249f" }, | ||
| ]} | ||
| axis={{ xLabel: "Month" }} | ||
| layout={{ height: 300 }} | ||
| showLegend | ||
| showBrush | ||
| /> | ||
| </DxcInset> | ||
| ); | ||
| };`; | ||
|
|
||
| export default { code, scope: {} }; |
16 changes: 16 additions & 0 deletions
16
apps/website/screens/guidelines/data-visualization/examples/rechartsPieExample.tsx
This file contains hidden or 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,16 @@ | ||
| const code = `() => { | ||
| const data = [ | ||
| { name: "Chrome", value: 48 }, | ||
| { name: "Safari", value: 32 }, | ||
| { name: "Firefox", value: 14 }, | ||
| { name: "Edge", value: 6 }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <DxcInset space="var(--spacing-padding-l)"> | ||
| <PieChart data={data} variant="donut" axis={{ showLabels: true }} layout={{ height: 320 }} showLegend /> | ||
| </DxcInset> | ||
| ); | ||
| };`; | ||
|
|
||
| export default { code, scope: {} }; |
164 changes: 164 additions & 0 deletions
164
apps/website/screens/guidelines/data-visualization/rechartsGuidelinesSection.tsx
This file contains hidden or 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,164 @@ | ||
| import { DxcBulletedList, DxcFlex, DxcParagraph, DxcLink, DxcTypography } from "@dxc-technology/halstack-react"; | ||
| import Link from "next/link"; | ||
| import Example from "@/common/example/Example"; | ||
| import type { SectionType } from "@/common/Section"; | ||
| import Code from "@/common/Code"; | ||
| import rechartsBarExample from "./examples/rechartsBarExample"; | ||
| import rechartsLineExample from "./examples/rechartsLineExample"; | ||
| import rechartsAreaExample from "./examples/rechartsAreaExample"; | ||
| import rechartsPieExample from "./examples/rechartsPieExample"; | ||
| import rechartsHorizontalBarExample from "./examples/rechartsHorizontalBarExample"; | ||
|
|
||
| /** Maintainer: set this to the published playground URL (single app with all five wrappers). */ | ||
| const CODE_SANDBOX_REFERENCE_APP = | ||
| "https://codesandbox.io/embed/recharts-examples-p3hg24?view=split&hidenavigation=1&editorsize=0&fontsize=12"; | ||
|
|
||
| export const rechartsGuidelinesSection: SectionType = { | ||
| title: "Recharts wrappers (alternative)", | ||
| content: ( | ||
| <> | ||
| <DxcParagraph> | ||
| Cloudscape remains our default recommendation for charting inside Halstack documentation and product patterns. | ||
| Some teams prefer a lighter, React-first charting stack.{" "} | ||
| <Link href="https://recharts.org/" passHref legacyBehavior> | ||
| <DxcLink>Recharts</DxcLink> | ||
| </Link>{" "} | ||
| composes well with custom layouts and Halstack primitives (for example <Code>DxcInset</Code>,{" "} | ||
| <Code>DxcFlex</Code>, and <Code>DxcContainer</Code>). | ||
| </DxcParagraph> | ||
| <DxcParagraph> | ||
| <DxcTypography fontWeight="var(--font-weight-bold)"> | ||
| Halstack does not ship chart components today | ||
| </DxcTypography> | ||
| . The examples below use a small set of reference wrappers—patterns you can recreate in your own codebase—to | ||
| cover typical analytics views: vertical bars (including grouped series), lines (with optional brush), filled | ||
| areas, part-to-whole pies and donuts, and horizontal percentage bars for KPI-style rows.{" "} | ||
| <DxcTypography fontWeight="var(--font-weight-bold)"> | ||
|
Jialecl marked this conversation as resolved.
Outdated
|
||
| They are illustrative, not a versioned API of the design system. | ||
| </DxcTypography> | ||
| </DxcParagraph> | ||
| <DxcParagraph> | ||
| Apply the same narrative guidance as the rest of this page (clear baselines, readable labels, sensible color | ||
| differentiation). Prefer Halstack categorical colors when you pass color or fill props so charts stay on-brand. | ||
| </DxcParagraph> | ||
| </> | ||
| ), | ||
| subSections: [ | ||
| { | ||
| title: "When to use", | ||
| content: ( | ||
| <DxcBulletedList> | ||
| <DxcBulletedList.Item> | ||
| Consider a thin Recharts wrapper layer when your product already standardizes on Recharts and you want | ||
| shared defaults for axes, grids, and tooltips. | ||
| </DxcBulletedList.Item> | ||
| <DxcBulletedList.Item> | ||
| Prefer Cloudscape charts when you need out-of-the-box AWS console patterns, their data-vis color tokens, or | ||
| parity with Cloudscape documentation. | ||
| </DxcBulletedList.Item> | ||
| <DxcBulletedList.Item> | ||
| Prefer raw Recharts when you need a chart type or behavior a wrapper does not expose yet. | ||
| </DxcBulletedList.Item> | ||
| </DxcBulletedList> | ||
| ), | ||
| }, | ||
| { | ||
| title: "CodeSandbox playground", | ||
| content: ( | ||
| <> | ||
| <DxcParagraph> | ||
| This page shows what the reference wrappers look like in context. For{" "} | ||
| <strong>prop definitions, defaults, limitations, and copy-paste source</strong>, open the companion | ||
| CodeSandbox: you can read each chart in depth and run the examples. | ||
| </DxcParagraph> | ||
| <DxcParagraph> | ||
| <iframe | ||
| src={CODE_SANDBOX_REFERENCE_APP} | ||
| style={{ | ||
| width: "100%", | ||
| aspectRatio: "16/9", | ||
| border: "0", | ||
| borderRadius: "4px", | ||
| overflow: "hidden", | ||
| zoom: 0.5, | ||
| }} | ||
| title="Application layout with components" | ||
| sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" | ||
| /> | ||
| </DxcParagraph> | ||
| <DxcParagraph>There you will find:</DxcParagraph> | ||
| <DxcBulletedList> | ||
| <DxcBulletedList.Item> | ||
| An overview of dependencies and how data is expected to be shaped. | ||
| </DxcBulletedList.Item> | ||
| <DxcBulletedList.Item> | ||
| A dedicated section for each wrapper—props, suggested use cases, and live demos. | ||
| </DxcBulletedList.Item> | ||
| <DxcBulletedList.Item> | ||
| Full source for all five components in one place so they stay in sync. | ||
| </DxcBulletedList.Item> | ||
| </DxcBulletedList> | ||
| </> | ||
| ), | ||
| }, | ||
| { | ||
| title: "Bar chart", | ||
| content: ( | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-l)"> | ||
| <DxcParagraph> | ||
| Compare categories or a few grouped series. Good default for quarterly metrics, counts by region, or | ||
| before/after snapshots. | ||
| </DxcParagraph> | ||
| <Example example={rechartsBarExample} defaultIsVisible onlyCode /> | ||
| </DxcFlex> | ||
| ), | ||
| }, | ||
| { | ||
| title: "Line chart", | ||
| content: ( | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-l)"> | ||
| <DxcParagraph> | ||
| Show trends over time or ordered categories. Optional brush helps when the horizontal domain is long. | ||
| </DxcParagraph> | ||
| <Example example={rechartsLineExample} defaultIsVisible onlyCode /> | ||
| </DxcFlex> | ||
| ), | ||
| }, | ||
| { | ||
| title: "Area chart", | ||
| content: ( | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-l)"> | ||
| <DxcParagraph> | ||
| Emphasize volume or cumulative change; gradients make stacked or overlapping series easier to read at a | ||
| glance. | ||
| </DxcParagraph> | ||
| <Example example={rechartsAreaExample} defaultIsVisible onlyCode /> | ||
| </DxcFlex> | ||
| ), | ||
| }, | ||
| { | ||
| title: "Pie chart", | ||
| content: ( | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-l)"> | ||
| <DxcParagraph> | ||
| Part-to-whole with pie or donut variants. Best for a small number of segments; pair with a table if | ||
| precision matters. | ||
| </DxcParagraph> | ||
| <Example example={rechartsPieExample} defaultIsVisible onlyCode /> | ||
| </DxcFlex> | ||
| ), | ||
| }, | ||
| { | ||
| title: "Horizontal bar (KPI row)", | ||
| content: ( | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-l)"> | ||
| <DxcParagraph> | ||
| Label + headline value + a 0-100 track—useful for scores, completion, or capability models without a full | ||
| Cartesian chart. | ||
| </DxcParagraph> | ||
| <Example example={rechartsHorizontalBarExample} defaultIsVisible onlyCode /> | ||
| </DxcFlex> | ||
| ), | ||
| }, | ||
| ], | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.