-
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.
* PieChart basico funcionando * Ui and utility changes * StraightAnglePieChart * Padding Angle View * Last ui changes and Linting * Customized Label * Pie Chart Controls dinamicos * Active Shape view * Ultimos cambios y linting * Deleted cooments
- Loading branch information
Showing
6 changed files
with
341 additions
and
112 deletions.
There are no files selected for viewing
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,67 @@ | ||
import React, { useState } from 'react'; | ||
import PieChart from '../../src/PieChart'; | ||
import Pie from '../../src/Pie'; | ||
import PolarGrid from '../../src/PolarGrid'; | ||
import Tooltip from '../../src/Tooltip'; | ||
import Legend from '../../src/Legend'; | ||
import PieChartControls from '../utils/PieChartControls'; | ||
|
||
const data01 = [ | ||
{ name: 'Group A', value: 400 }, | ||
{ name: 'Group B', value: 300 }, | ||
{ name: 'Group C', value: 300 }, | ||
{ name: 'Group D', value: 200 }, | ||
{ name: 'Group E', value: 278 }, | ||
{ name: 'Group F', value: 189 }, | ||
]; | ||
|
||
const CustomActiveShapePieChart: React.FC = () => { | ||
const [pies, setPies] = useState([ | ||
{ | ||
id: 1, | ||
innerRadius: 0, | ||
outerRadius: 80, | ||
cx: '50%', | ||
cy: '50%', | ||
showLabels: true, | ||
startAngle: 0, | ||
endAngle: 360, | ||
label: 'percent', | ||
activeShape: true, | ||
}, | ||
]); | ||
const [showPolarGrid, setShowPolarGrid] = useState(true); | ||
|
||
return ( | ||
<div className="p-6"> | ||
<h1 className="text-2xl font-semibold mb-4">Custom Active Shape Pie Chart</h1> | ||
<div className="flex gap-6"> | ||
<PieChartControls pies={pies} setPies={setPies} showPolarGrid={showPolarGrid} setShowPolarGrid={setShowPolarGrid} /> | ||
<PieChart width={730} height={250}> | ||
{showPolarGrid && <PolarGrid />} | ||
{pies.map((pie) => ( | ||
<Pie | ||
key={pie.id} | ||
data={data01} | ||
dataKey="value" | ||
nameKey="name" | ||
cx={pie.cx} | ||
cy={pie.cy} | ||
innerRadius={pie.innerRadius} | ||
outerRadius={pie.outerRadius} | ||
startAngle={pie.startAngle} | ||
endAngle={pie.endAngle} | ||
fill="#8884d8" | ||
label={pie.label} | ||
activeShape={pie.activeShape} | ||
/> | ||
))} | ||
<Tooltip /> | ||
<Legend /> | ||
</PieChart> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CustomActiveShapePieChart; |
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,70 @@ | ||
import React, { useState } from 'react'; | ||
import PieChart from '../../src/PieChart'; | ||
import Pie from '../../src/Pie'; | ||
import PolarGrid from '../../src/PolarGrid'; | ||
import Tooltip from '../../src/Tooltip'; | ||
import Legend from '../../src/Legend'; | ||
import PieChartControls from '../utils/PieChartControls'; | ||
|
||
const data01 = [ | ||
{ "name": "Group A", "value": 400 }, | ||
{ "name": "Group B", "value": 300 }, | ||
{ "name": "Group C", "value": 300 }, | ||
{ "name": "Group D", "value": 200 }, | ||
{ "name": "Group E", "value": 278 }, | ||
{ "name": "Group F", "value": 189 } | ||
]; | ||
|
||
const PieChartWithCustomizedLabel: React.FC = () => { | ||
const [pies, setPies] = useState([ | ||
{ | ||
id: 1, | ||
innerRadius: 0, | ||
outerRadius: 80, | ||
cx: '50%', | ||
cy: '50%', | ||
showLabels: true, | ||
startAngle: 0, | ||
endAngle: 360, | ||
label: ['A', 'B', 'C', 'D', 'E', 'F'], | ||
}, | ||
]); | ||
const [showPolarGrid, setShowPolarGrid] = useState(true); | ||
|
||
return ( | ||
<div className="p-6"> | ||
<h1 className="text-2xl font-semibold mb-4">PieChart With Customized Label</h1> | ||
<div className="flex"> | ||
<PieChartControls | ||
pies={pies} | ||
setPies={setPies} | ||
showPolarGrid={showPolarGrid} | ||
setShowPolarGrid={setShowPolarGrid} | ||
/> | ||
<PieChart width={730} height={250}> | ||
{showPolarGrid && <PolarGrid />} | ||
{pies.map((pie) => ( | ||
<Pie | ||
key={pie.id} | ||
data={data01} | ||
dataKey="value" | ||
nameKey="name" | ||
cx={pie.cx} | ||
cy={pie.cy} | ||
innerRadius={pie.innerRadius} | ||
outerRadius={pie.outerRadius} | ||
startAngle={pie.startAngle} | ||
endAngle={pie.endAngle} | ||
fill="#8884d8" | ||
label={pie.showLabels ? pie.label : false} | ||
/> | ||
))} | ||
<Tooltip /> | ||
<Legend /> | ||
</PieChart> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PieChartWithCustomizedLabel; |
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.