diff --git a/samples/App.tsx b/samples/App.tsx index 2d8452b..822004f 100644 --- a/samples/App.tsx +++ b/samples/App.tsx @@ -3,6 +3,7 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import NavBar from './utils/NavBar'; import NormalBarChart from './pages/NormalBarChart'; import StackedBarChart from './pages/StackedBarChart'; +import RangedBarChart from './pages/RangedBarChart'; const App = () => { return ( @@ -12,6 +13,7 @@ const App = () => { } /> } /> + } /> diff --git a/samples/pages/RangedBarChart.tsx b/samples/pages/RangedBarChart.tsx new file mode 100644 index 0000000..bcbc8c2 --- /dev/null +++ b/samples/pages/RangedBarChart.tsx @@ -0,0 +1,76 @@ +import React, { useState } from 'react'; +import { BarChart, CartesianGrid, XAxis, YAxis, Tooltip, Legend, Bar } from '../../src'; +import BarChartControls from '../utils/BarChartControls'; + +const RangedBarChart = () => { + const [width, setWidth] = useState(600); + const [height, setHeight] = useState(400); + const [barCategoryGap, setBarCategoryGap] = useState('10%'); + const [barGap, setBarGap] = useState(4); + const [layout, setLayout] = useState<'horizontal' | 'vertical'>('horizontal'); + const [margin, setMargin] = useState({ top: 5, right: 5, bottom: 5, left: 5 }); + const [showXAxis, setShowXAxis] = useState(true); + const [showYAxis, setShowYAxis] = useState(true); + const [showCartesianGrid, setShowCartesianGrid] = useState(true); + const [showTooltip, setShowTooltip] = useState(true); + const [showLegend, setShowLegend] = useState(true); + + const data = [ + { name: '05-01', temperature: [-6, 12] }, + { name: '05-02', temperature: [6, 12] }, + { name: '05-03', temperature: [3, 12] }, + { name: '05-04', temperature: [4, 12] }, + { name: '05-05', temperature: [12, 15] }, + { name: '05-06', temperature: [5, 15] }, + { name: '05-07', temperature: [3, 12] }, + { name: '05-08', temperature: [0, 8] }, + { name: '05-09', temperature: [-3, 5] }, + ]; + + return ( +
+ + + {showCartesianGrid && } + {showXAxis && } + {showYAxis && } + {showTooltip && } + {showLegend && } + + +
+ ); +}; + +export default RangedBarChart; diff --git a/samples/utils/NavBar.tsx b/samples/utils/NavBar.tsx index b045700..f75907a 100644 --- a/samples/utils/NavBar.tsx +++ b/samples/utils/NavBar.tsx @@ -1,16 +1,19 @@ import React from 'react'; import { Link } from 'react-router-dom'; -const NavBar: React.FC = () => { +const NavBar = () => { return ( -