-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Primer avance pruebas * All piechart tests passed * Fixes and linting * LineChart Inicial * Fixed labels and line positioning * Ui changes on all controls * Last fixes and linting * Fixed double rendering and YAxis values * Added DashedLineChart and Line types * LineChart Wrapper to fix duplicated code * Support for legend * Support for Tooltip * Linting and final fixes
- Loading branch information
Showing
10 changed files
with
273 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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,13 @@ | ||
import React from 'react'; | ||
import LineChartWrapper from '../utils/LineChartWrapper'; | ||
|
||
const DashedLineChart = () => { | ||
const initialLines = [ | ||
{ id: 1, stroke: '#8884d8', dataKey: 'pv', strokeDasharray: '5 5', type: 'linear' }, | ||
{ id: 2, stroke: '#82ca9d', dataKey: 'uv', strokeDasharray: '3 3', type: 'monotoneX' }, | ||
]; | ||
|
||
return <LineChartWrapper initialLines={initialLines} />; | ||
}; | ||
|
||
export default DashedLineChart; |
This file contains 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 |
---|---|---|
@@ -1,58 +1,13 @@ | ||
import React, { useState } from 'react'; | ||
import LineChart from '../../src/LineChart'; | ||
import Line from '../../src/Line'; | ||
import CartesianGrid from '../../src/CartesianGrid'; | ||
import XAxis from '../../src/XAxis'; | ||
import YAxis from '../../src/YAxis'; | ||
import Tooltip from '../../src/Tooltip'; | ||
import Legend from '../../src/Legend'; | ||
import LineChartControls from '../utils/LineChartControls'; | ||
import React from 'react'; | ||
import LineChartWrapper from '../utils/LineChartWrapper'; | ||
|
||
const data = [ | ||
{ name: 'Page A', uv: 4000, pv: 2400, amt: 2400 }, | ||
{ name: 'Page B', uv: 3000, pv: 1398, amt: 2210 }, | ||
{ name: 'Page C', uv: 2000, pv: 9800, amt: 2290 }, | ||
{ name: 'Page D', uv: 2780, pv: 3908, amt: 2000 }, | ||
{ name: 'Page E', uv: 1890, pv: 4800, amt: 2181 }, | ||
{ name: 'Page F', uv: 2390, pv: 3800, amt: 2500 }, | ||
{ name: 'Page G', uv: 3490, pv: 4300, amt: 2100 }, | ||
]; | ||
const LineChartExample = () => { | ||
const initialLines = [ | ||
{ id: 1, stroke: '#8884d8', dataKey: 'pv', type: 'monotone' }, | ||
{ id: 2, stroke: '#82ca9d', dataKey: 'uv', type: 'linear' }, | ||
]; | ||
|
||
const LineChartExample: React.FC = () => { | ||
const [lines, setLines] = useState([ | ||
{ id: 1, stroke: '#8884d8', dataKey: 'pv' }, | ||
{ id: 2, stroke: '#82ca9d', dataKey: 'uv' }, | ||
]); | ||
const [width, setWidth] = useState(730); | ||
const [height, setHeight] = useState(250); | ||
const [margin, setMargin] = useState({ top: 5, right: 30, left: 20, bottom: 5 }); | ||
|
||
return ( | ||
<div className="p-6"> | ||
<div className="flex"> | ||
<LineChartControls | ||
lines={lines} | ||
setLines={setLines} | ||
width={width} | ||
setWidth={setWidth} | ||
height={height} | ||
setHeight={setHeight} | ||
margin={margin} | ||
setMargin={setMargin} | ||
/> | ||
<LineChart width={width} height={height} data={data} margin={margin}> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey="name" /> | ||
<YAxis /> | ||
<Tooltip /> | ||
<Legend /> | ||
{lines.map((line) => ( | ||
<Line key={line.id} type="monotone" dataKey={line.dataKey} stroke={line.stroke} /> | ||
))} | ||
</LineChart> | ||
</div> | ||
</div> | ||
); | ||
return <LineChartWrapper initialLines={initialLines} />; | ||
}; | ||
|
||
export default LineChartExample; | ||
export default LineChartExample; |
This file contains 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 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,61 @@ | ||
import React, { useState } from 'react'; | ||
import LineChart from '../../src/LineChart'; | ||
import Line from '../../src/Line'; | ||
import CartesianGrid from '../../src/CartesianGrid'; | ||
import XAxis from '../../src/XAxis'; | ||
import YAxis from '../../src/YAxis'; | ||
import Tooltip from '../../src/Tooltip'; | ||
import Legend from '../../src/Legend'; | ||
import LineChartControls from './LineChartControls'; | ||
|
||
const data = [ | ||
{ name: 'Page A', uv: 4000, pv: 2400, amt: 2400 }, | ||
{ name: 'Page B', uv: 3000, pv: 1398, amt: 2210 }, | ||
{ name: 'Page C', uv: 2000, pv: 9800, amt: 2290 }, | ||
{ name: 'Page D', uv: 2780, pv: 3908, amt: 2000 }, | ||
{ name: 'Page E', uv: 1890, pv: 4800, amt: 2181 }, | ||
{ name: 'Page F', uv: 2390, pv: 3800, amt: 2500 }, | ||
{ name: 'Page G', uv: 3490, pv: 4300, amt: 2100 }, | ||
]; | ||
|
||
const LineChartWrapper = ({ initialLines }) => { | ||
const [lines, setLines] = useState(initialLines); | ||
const [width, setWidth] = useState(730); | ||
const [height, setHeight] = useState(250); | ||
const [margin, setMargin] = useState({ top: 5, right: 30, left: 20, bottom: 5 }); | ||
|
||
return ( | ||
<div className="p-6"> | ||
<div className="flex"> | ||
<LineChartControls | ||
lines={lines} | ||
setLines={setLines} | ||
width={width} | ||
setWidth={setWidth} | ||
height={height} | ||
setHeight={setHeight} | ||
margin={margin} | ||
setMargin={setMargin} | ||
/> | ||
<LineChart width={width} height={height} data={data} margin={margin}> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey="name" /> | ||
<YAxis /> | ||
<Tooltip /> | ||
<Legend /> | ||
{lines.map((line) => ( | ||
<Line | ||
key={line.id} | ||
type={line.type} | ||
dataKey={line.dataKey} | ||
stroke={line.stroke} | ||
strokeDasharray={line.strokeDasharray} | ||
/> | ||
))} | ||
</LineChart> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LineChartWrapper; |
This file contains 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 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
Oops, something went wrong.