Loading...
Loading...
Guide for creating data visualizations in Shopify Apps using the Polaris Viz library. Use this skill when building charts, graphs, dashboards, or any data visualization components that need to integrate with the Shopify Admin aesthetic. Covers BarChart, LineChart, DonutChart, SparkLineChart, and theming.
npx skill4agent add toilahuongg/shopify-agents-kit shopify-polaris-vizNote: This library was archived in June 2025. While still functional, Shopify recommends reaching out to support for migration assistance if building new features.
npm install @shopify/polaris-viz
# Required peer dependencies
npm install @shopify/polaris @shopify/polaris-tokensPolarisVizProviderimport { PolarisVizProvider } from '@shopify/polaris-viz';
import '@shopify/polaris-viz/build/esm/styles.css';
function App() {
return (
<PolarisVizProvider>
{/* Your app */}
</PolarisVizProvider>
);
}| Component | Use Case | Max Data Points |
|---|---|---|
| Comparing discrete categories | ~6 categories |
| Simple horizontal bars | ~6 categories |
| Trends over time | 30+ points |
| Compact inline trends | Any |
| Part-to-whole relationships | ~6 segments |
| Cumulative trends | 30+ points |
| Conversion funnels | ~6 stages |
import { BarChart } from '@shopify/polaris-viz';
const data = [
{
name: 'Sales',
data: [
{ key: 'Monday', value: 150 },
{ key: 'Tuesday', value: 200 },
{ key: 'Wednesday', value: 175 },
],
},
];
<BarChart data={data} />import { LineChart } from '@shopify/polaris-viz';
const data = [
{
name: 'Orders',
data: [
{ key: 'Jan', value: 100 },
{ key: 'Feb', value: 150 },
{ key: 'Mar', value: 200 },
],
},
];
<LineChart data={data} />import { DonutChart } from '@shopify/polaris-viz';
const data = [
{ name: 'Direct', data: [{ key: 'Direct', value: 200 }] },
{ name: 'Social', data: [{ key: 'Social', value: 150 }] },
{ name: 'Email', data: [{ key: 'Email', value: 100 }] },
];
<DonutChart data={data} />import { SparkLineChart } from '@shopify/polaris-viz';
const data = [
{
data: [
{ key: 0, value: 100 },
{ key: 1, value: 150 },
{ key: 2, value: 120 },
{ key: 3, value: 180 },
],
},
];
<SparkLineChart data={data} />DataSeriesinterface DataPoint {
key: string | number; // X-axis value or category
value: number | null; // Y-axis value (null for gaps)
}
interface DataSeries {
name: string; // Series label
data: DataPoint[]; // Array of data points
color?: string; // Optional color override
isComparison?: boolean; // Mark as comparison data (renders grey)
}theme// Use built-in themes
<BarChart data={data} theme="Light" />
<BarChart data={data} theme="Dark" />
// Or define custom themes in provider
<PolarisVizProvider
themes={{
MyBrand: {
chartContainer: { backgroundColor: '#f9f9f9' },
seriesColors: { upToEight: ['#5c6ac4', '#47c1bf'] },
},
}}
>
<BarChart data={data} theme="MyBrand" />
</PolarisVizProvider>| Prop | Type | Description |
|---|---|---|
| | Chart data |
| | Theme name |
| | Enable/disable animations |
| | Show legend |
| | X-axis configuration |
| | Y-axis configuration |
| | Text when no data |