Skip to content

Commit fbf04df

Browse files
author
iexitdev
committed
Add Pro chart docs previews
1 parent b6d1097 commit fbf04df

17 files changed

Lines changed: 1314 additions & 11 deletions

.github/workflows/site.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Site
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- next
9+
paths:
10+
- ".github/workflows/site.yml"
11+
- "apps/site/**"
12+
- "docs/**"
13+
- "packages/**"
14+
- "package-lock.json"
15+
- "package.json"
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
env:
21+
CHART_KIT_PRO_NPM_TOKEN: ${{ secrets.CHART_KIT_PRO_NPM_TOKEN }}
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v5
26+
27+
- name: Setup Node
28+
uses: actions/setup-node@v5
29+
with:
30+
node-version: 22
31+
cache: npm
32+
33+
- name: Install dependencies
34+
run: npm ci --ignore-scripts
35+
36+
- name: Install Pro docs package
37+
run: |
38+
if [ -n "$CHART_KIT_PRO_NPM_TOKEN" ]; then
39+
npm config set //registry.npmjs.org/:_authToken "$CHART_KIT_PRO_NPM_TOKEN"
40+
npm install --no-save --package-lock=false --ignore-scripts @chart-kit/pro
41+
echo "CHART_KIT_PRO_DOCS=true" >> "$GITHUB_ENV"
42+
else
43+
echo "CHART_KIT_PRO_NPM_TOKEN is not set; building with local Pro docs stubs."
44+
fi
45+
46+
- name: Build site
47+
run: npm run site:build

apps/site/astro.config.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ const expoVectorIconsStub = localSource(
2525
const svgTransformParserStub = localSource(
2626
"./src/previews/svgTransformParserStub.ts"
2727
);
28+
const useRealProCharts = process.env.CHART_KIT_PRO_DOCS === "true";
29+
const chartKitProAliases = useRealProCharts
30+
? []
31+
: [
32+
{
33+
find: /^@chart-kit\/pro$/,
34+
replacement: localSource("./src/previews/proStub.tsx")
35+
}
36+
];
2837

2938
const chartKitPreviewWebAliases = () => ({
3039
name: "chart-kit-preview-web-aliases",
@@ -95,6 +104,14 @@ export default defineConfig({
95104
{ slug: docsSlug("charts/contribution-heatmap") }
96105
]
97106
},
107+
{
108+
label: "Pro Charts",
109+
items: [
110+
{ slug: docsSlug("charts/candlebar") },
111+
{ slug: docsSlug("charts/radar") },
112+
{ slug: docsSlug("charts/combo") }
113+
]
114+
},
98115
{
99116
label: "Guides",
100117
items: [
@@ -125,6 +142,7 @@ export default defineConfig({
125142
"react-native",
126143
"react-native-chart-kit",
127144
"react-native-chart-kit/v2",
145+
"@chart-kit/pro",
128146
"react-native-gesture-handler",
129147
"react-native-svg"
130148
]
@@ -147,6 +165,7 @@ export default defineConfig({
147165
find: /^@chart-kit\/svg-renderer$/,
148166
replacement: packageSource("svg-renderer/src/index.ts")
149167
},
168+
...chartKitProAliases,
150169
{
151170
find: /^react-native$/,
152171
replacement: reactNativeWebStub

apps/site/src/components/ChartsSupported.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,24 @@ const chartTypes: ChartType[] = [
6060
kind: "heatmap",
6161
title: "Contribution Heatmap"
6262
},
63-
{ kind: "radar", pro: true, subtitle: "planned", title: "Radar Chart" },
64-
{ kind: "combined", pro: true, title: "Combined Chart" },
65-
{ kind: "candlestick", pro: true, title: "Candlestick Chart" },
63+
{
64+
docsHref: `${docsBaseHref}/charts/radar/`,
65+
kind: "radar",
66+
pro: true,
67+
title: "Radar Chart"
68+
},
69+
{
70+
docsHref: `${docsBaseHref}/charts/combo/`,
71+
kind: "combined",
72+
pro: true,
73+
title: "Combo Chart"
74+
},
75+
{
76+
docsHref: `${docsBaseHref}/charts/candlebar/`,
77+
kind: "candlestick",
78+
pro: true,
79+
title: "Candlebar Chart"
80+
},
6681
{ kind: "more", title: "More charts", subtitle: "coming soon" }
6782
];
6883

apps/site/src/lib/remark-strip-duplicate-title.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,17 @@ const playgroundDocs = new Set([
114114
"charts/area.md",
115115
"charts/bar.md",
116116
"charts/contribution-heatmap.md",
117+
"charts/candlebar.md",
118+
"charts/combo.md",
117119
"charts/donut.md",
118120
"charts/line.md",
119121
"charts/pie.md",
120-
"charts/progress.md"
122+
"charts/progress.md",
123+
"charts/radar.md"
121124
]);
122125

123126
const chartComponentPattern =
124-
/<\s*(AreaChart|BarChart|ContributionGraph|DonutChart|LineChart|PieChart|ProgressChart|ProgressRing|StackedBarChart)\b/;
127+
/<\s*(AreaChart|BarChart|CandlebarChart|CandlestickChart|ComboChart|ContributionGraph|DonutChart|LineChart|PieChart|ProgressChart|ProgressRing|RadarChart|StackedBarChart)\b/;
125128

126129
const slugify = (value) =>
127130
String(value)

apps/site/src/previews/ChartPlayground.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
StackedBarChart,
3030
type ChartKitThemeMode
3131
} from "react-native-chart-kit/v2";
32+
import { CandlebarChart, ComboChart, RadarChart } from "@chart-kit/pro";
3233
import { G, Line as SvgLine, Rect, Text as SvgText } from "react-native-svg";
3334

3435
import {
@@ -38,7 +39,9 @@ import {
3839
} from "./chartTheme";
3940
import {
4041
acquisitionShare,
42+
candlebarPrices,
4143
clampChartWidth,
44+
comboRevenue,
4245
contributionEndDate,
4346
contributionNumDays,
4447
contributionValues,
@@ -48,6 +51,7 @@ import {
4851
platformShare,
4952
profit,
5053
progressRings,
54+
radarBenchmarks,
5155
revenueMix,
5256
signedMoney,
5357
signups,
@@ -279,7 +283,10 @@ const retentionSegments = [
279283
const previewDataById: Record<string, unknown[]> = {
280284
"bar-grouped": barPlaygroundData,
281285
"line-multi-series": linePlaygroundData,
282-
"line-selection": linePlaygroundData
286+
"line-selection": linePlaygroundData,
287+
"pro-candlebar": candlebarPrices,
288+
"pro-combo": comboRevenue,
289+
"pro-radar": radarBenchmarks
283290
};
284291

285292
const getPreviewData = (id: string) =>
@@ -485,22 +492,27 @@ export const ChartPlayground = ({ code, id }: { code: string; id: string }) => {
485492
() => ({
486493
AreaChart,
487494
BarChart,
495+
CandlebarChart,
488496
ContributionGraph,
489497
ChartKitProvider,
498+
ComboChart,
490499
DonutChart,
491500
G,
492501
LineChart,
493502
PieChart,
494503
ProgressChart,
495504
ProgressRing,
505+
RadarChart,
496506
React,
497507
Rect,
498508
StackedBarChart,
499509
SvgText,
500510
Text,
501511
View,
502512
acquisitionShare: acquisitionSharePlaygroundData,
513+
candlebarPrices,
503514
clampChartWidth,
515+
comboRevenue,
504516
contributionValues,
505517
contributionEndDate,
506518
contributionNumDays,
@@ -517,6 +529,7 @@ export const ChartPlayground = ({ code, id }: { code: string; id: string }) => {
517529
previewWidth: clampChartWidth(width),
518530
profit,
519531
progressRings,
532+
radarBenchmarks,
520533
revenueMix: revenueMixPlaygroundData,
521534
retentionSegments,
522535
signedMoney,

apps/site/src/previews/data.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,38 @@ export const contributionValues = Array.from(
9999
};
100100
}
101101
);
102+
103+
export const candlebarPrices = [
104+
{ date: "09:30", open: 184, high: 196, low: 179, close: 191, volume: 42 },
105+
{ date: "10:00", open: 191, high: 208, low: 188, close: 202, volume: 68 },
106+
{ date: "10:30", open: 202, high: 206, low: 185, close: 189, volume: 74 },
107+
{ date: "11:00", open: 189, high: 215, low: 186, close: 211, volume: 95 },
108+
{ date: "11:30", open: 211, high: 226, low: 204, close: 219, volume: 88 },
109+
{ date: "12:00", open: 219, high: 221, low: 198, close: 204, volume: 81 },
110+
{ date: "12:30", open: 204, high: 232, low: 201, close: 228, volume: 118 },
111+
{ date: "13:00", open: 228, high: 236, low: 214, close: 217, volume: 101 },
112+
{ date: "13:30", open: 217, high: 244, low: 216, close: 239, volume: 132 },
113+
{ date: "14:00", open: 239, high: 248, low: 226, close: 231, volume: 109 },
114+
{ date: "14:30", open: 231, high: 252, low: 229, close: 247, volume: 124 },
115+
{ date: "15:00", open: 247, high: 258, low: 236, close: 241, volume: 116 }
116+
];
117+
118+
export const radarBenchmarks = [
119+
{ metric: "Speed", current: 82, target: 92, industry: 68 },
120+
{ metric: "Polish", current: 76, target: 88, industry: 61 },
121+
{ metric: "A11y", current: 90, target: 94, industry: 72 },
122+
{ metric: "Depth", current: 68, target: 84, industry: 55 },
123+
{ metric: "Control", current: 86, target: 91, industry: 65 },
124+
{ metric: "Export", current: 72, target: 86, industry: 58 }
125+
];
126+
127+
export const comboRevenue = [
128+
{ month: "Jan", revenue: 420, forecast: 480, margin: 128 },
129+
{ month: "Feb", revenue: 560, forecast: 530, margin: 168 },
130+
{ month: "Mar", revenue: 490, forecast: 610, margin: 151 },
131+
{ month: "Apr", revenue: 720, forecast: 690, margin: 214 },
132+
{ month: "May", revenue: 640, forecast: 760, margin: 193 },
133+
{ month: "Jun", revenue: 880, forecast: 840, margin: 276 },
134+
{ month: "Jul", revenue: 790, forecast: 920, margin: 244 },
135+
{ month: "Aug", revenue: 1040, forecast: 980, margin: 331 }
136+
];

apps/site/src/previews/examples.tsx

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ type PreviewRenderContext = {
1717
};
1818

1919
export type ChartPreviewExample = {
20+
ctaHref?: string;
21+
ctaLabel?: string;
22+
description?: string;
2023
eyebrow: string;
2124
id: string;
2225
render: (context: PreviewRenderContext) => ReactNode;
2326
supportsChartTheme?: boolean;
27+
tier?: "free" | "pro";
2428
title: string;
2529
};
2630

@@ -51,7 +55,20 @@ export const renderChartPreview = ({
5155
>
5256
<View style={previewStyles.shell}>
5357
<View style={previewStyles.header}>
54-
<Text style={previewStyles.eyebrow}>{example.eyebrow}</Text>
58+
<View style={previewStyles.metaRow}>
59+
<Text style={previewStyles.eyebrow}>{example.eyebrow}</Text>
60+
{example.tier === "pro" ? (
61+
<Text
62+
accessibilityLabel="Available in Chart Kit Pro"
63+
style={[
64+
previewStyles.proBadge,
65+
mode === "dark" && previewStyles.proBadgeDark
66+
]}
67+
>
68+
Pro
69+
</Text>
70+
) : null}
71+
</View>
5572
<Text
5673
style={[
5774
previewStyles.title,
@@ -60,10 +77,28 @@ export const renderChartPreview = ({
6077
>
6178
{example.title}
6279
</Text>
80+
{example.description ? (
81+
<Text
82+
style={[
83+
previewStyles.description,
84+
mode === "dark" && previewStyles.descriptionDark
85+
]}
86+
>
87+
{example.description}
88+
</Text>
89+
) : null}
6390
</View>
6491
<View style={previewStyles.chart}>
6592
{example.render({ chartThemePreset, mode, width: width - 2 })}
6693
</View>
94+
{example.tier === "pro" ? (
95+
<a
96+
className="chart-kit-live-preview__pro-link"
97+
href={example.ctaHref ?? "/#pricing"}
98+
>
99+
{example.ctaLabel ?? "View Pro plans"}
100+
</a>
101+
) : null}
67102
</View>
68103
</ChartKitProvider>
69104
);
@@ -84,6 +119,24 @@ const previewStyles = {
84119
header: {
85120
marginBottom: 16
86121
},
122+
description: {
123+
color: "rgba(7, 23, 51, 0.62)",
124+
fontSize: 14,
125+
fontWeight: "400" as const,
126+
letterSpacing: 0,
127+
lineHeight: 21,
128+
marginTop: 8,
129+
maxWidth: 540
130+
},
131+
descriptionDark: {
132+
color: "rgba(255, 255, 255, 0.62)"
133+
},
134+
metaRow: {
135+
alignItems: "center" as const,
136+
flexDirection: "row" as const,
137+
gap: 8,
138+
marginBottom: 8
139+
},
87140
missing: {
88141
backgroundColor: "#ffffff",
89142
borderColor: "rgba(16, 18, 23, 0.14)",
@@ -99,6 +152,25 @@ const previewStyles = {
99152
shell: {
100153
width: "100%" as const
101154
},
155+
proBadge: {
156+
backgroundColor: "rgba(15, 58, 120, 0.1)",
157+
borderColor: "rgba(15, 58, 120, 0.18)",
158+
borderRadius: 999,
159+
borderWidth: 1,
160+
color: "#0f3a78",
161+
fontSize: 11,
162+
fontWeight: "800" as const,
163+
letterSpacing: 0,
164+
lineHeight: 18,
165+
overflow: "hidden" as const,
166+
paddingHorizontal: 8,
167+
textTransform: "uppercase" as const
168+
},
169+
proBadgeDark: {
170+
backgroundColor: "rgba(216, 230, 255, 0.1)",
171+
borderColor: "rgba(216, 230, 255, 0.18)",
172+
color: "#d8e6ff"
173+
},
102174
title: {
103175
color: "#101217",
104176
fontSize: 28,

0 commit comments

Comments
 (0)