import React, { useState } from 'react' import { NextChartist, useChartist } from 'next-chartist' import './App.css' const App: React.FC = () => { const [activeTab, setActiveTab] = useState<'line' | 'bar' | 'pie' | 'hook'>('line') // Example data for different chart types const lineChartData = { labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], series: [ [5, 2, 4, 2, 0, 3, 5], [2, 3, 3, 1, 4, 5, 3] ] } const barChartData = { labels: ['Q1', 'Q2', 'Q3', 'Q4'], series: [ [800000, 1200000, 1400000, 1300000], [200000, 400000, 500000, 300000], [100000, 200000, 400000, 600000] ] } const pieChartData = { labels: ['Bananas', 'Apples', 'Grapes', 'Oranges'], series: [20, 15, 40, 25] } const lineChartOptions = { fullWidth: true, chartPadding: { right: 40 }, low: 0 } const barChartOptions = { stackBars: true, axisY: { labelInterpolationFnc: function(value: number) { return (value / 1000) + 'k' } } } const pieChartOptions = { labelInterpolationFnc: function(value: number) { return value + '%' } } const responsiveOptions = [ ['screen and (min-width: 640px)', { chartPadding: { right: 40 } }] ] return (

📊 NextChartist Examples

React Chartist component for Next.js with TypeScript support

{activeTab === 'line' && (

Line Chart Example

Multi-series line chart with responsive options

{``}
)} {activeTab === 'bar' && (

Bar Chart Example

Stacked bar chart with custom axis formatting

{` (value / 1000) + 'k'
    }
  }}
/>`}
)} {activeTab === 'pie' && (

Pie Chart Example

Pie chart with percentage labels

{` value + '%'
  }}
/>`}
)} {activeTab === 'hook' && ( )}
) } // Hook Example Component const HookExample: React.FC = () => { const { ChartComponent, updateChart } = useChartist( 'LineChart', { labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'], series: [[10, 15, 12, 17, 20]] }, { fullWidth: true, low: 0 } ) const handleUpdate = () => { updateChart({ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'], series: [[10, 15, 12, 17, 20, 25]] }) } return (

useChartist Hook Example

Using the useChartist hook to manage chart state

{ChartComponent}
{`const { ChartComponent, updateChart } = useChartist(
  'LineChart',
  {
    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    series: [[10, 15, 12, 17, 20]]
  },
  {
    fullWidth: true,
    low: 0
  }
)

// Update chart
updateChart({
  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
  series: [[10, 15, 12, 17, 20, 25]]
})`}
) } export default App