-
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.
1. 岗位分类分布 饼图 2. 公司分布 TreeMap 3. 经验要求分析 半饼图 4. 薪资分析 金字塔图
- Loading branch information
1 parent
fa51963
commit 018f04f
Showing
11 changed files
with
543 additions
and
80 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
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,57 @@ | ||
import * as echarts from "echarts/core"; | ||
import { PieChart } from "echarts/charts"; | ||
import { LabelLayout } from "echarts/features"; | ||
import { CanvasRenderer } from "echarts/renderers"; | ||
import EChartsReactCore from "echarts-for-react/lib/core"; | ||
import PropTypes from "prop-types"; | ||
|
||
echarts.use([PieChart, CanvasRenderer, LabelLayout]); | ||
|
||
const optionSample = { | ||
series: [ | ||
{ | ||
type: "pie", | ||
radius: "25%", | ||
center: ["50%", "50%"], | ||
data: [], | ||
label: { | ||
position: "outer", | ||
alignTo: "edge", | ||
// edgeDistance: "25%", | ||
}, | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0, | ||
}, | ||
], | ||
}; | ||
|
||
export default function BasicPieChart({ items, data, onChartReady, ...props }) { | ||
if (data.length === 0) { | ||
return <div className="h-64"></div>; | ||
} | ||
|
||
console.log(items); | ||
let option = optionSample; | ||
const chartdata = []; | ||
for (let i = 0; i < items.length; i++) { | ||
chartdata.push({ value: data[i], name: items[i] }); | ||
} | ||
option.series[0].data = chartdata; | ||
|
||
return ( | ||
<EChartsReactCore | ||
echarts={echarts} | ||
option={option} | ||
onChartReady={onChartReady} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
BasicPieChart.propTypes = { | ||
items: PropTypes.array.isRequired, | ||
data: PropTypes.array.isRequired, | ||
onChartReady: PropTypes.func.isRequired, | ||
}; |
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,100 @@ | ||
import * as echarts from "echarts/core"; | ||
import { LegendComponent } from "echarts/components"; | ||
import { PieChart } from "echarts/charts"; | ||
import { LabelLayout } from "echarts/features"; | ||
import { CanvasRenderer } from "echarts/renderers"; | ||
import EChartsReactCore from "echarts-for-react/lib/core"; | ||
import PropTypes from "prop-types"; | ||
|
||
echarts.use([LegendComponent, PieChart, CanvasRenderer, LabelLayout]); | ||
|
||
const optionSample = { | ||
legend: { | ||
top: "5%", | ||
left: "center", | ||
// doesn't perfectly work with our tricks, disable it | ||
selectedMode: false, | ||
}, | ||
series: [ | ||
{ | ||
name: "Access From", | ||
type: "pie", | ||
radius: ["40%", "70%"], | ||
center: ["50%", "70%"], | ||
// adjust the start angle | ||
startAngle: 180, | ||
label: { | ||
show: true, | ||
formatter(param) { | ||
// correct the percentage | ||
return param.name + " (" + param.percent * 2 + "%)"; | ||
}, | ||
}, | ||
data: [ | ||
{ value: 1048, name: "Search Engine" }, | ||
{ value: 735, name: "Direct" }, | ||
{ value: 580, name: "Email" }, | ||
{ value: 484, name: "Union Ads" }, | ||
{ value: 300, name: "Video Ads" }, | ||
{ | ||
// make an record to fill the bottom 50% | ||
value: 1048 + 735 + 580 + 484 + 300, | ||
itemStyle: { | ||
// stop the chart from rendering this piece | ||
color: "none", | ||
decal: { | ||
symbol: "none", | ||
}, | ||
}, | ||
label: { | ||
show: false, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
export default function HalfPieChart({ items, data, onChartReady, ...props }) { | ||
if (data.length === 0) { | ||
return <div className="h-64"></div>; | ||
} | ||
|
||
let option = optionSample; | ||
const chartdata = []; | ||
let sum = 0; | ||
for (let i = 0; i < items.length; i++) { | ||
chartdata.push({ value: data[i], name: items[i] }); | ||
sum += data[i]; | ||
} | ||
chartdata.push({ | ||
// make an record to fill the bottom 50% | ||
value: sum, | ||
itemStyle: { | ||
// stop the chart from rendering this piece | ||
color: "none", | ||
decal: { | ||
symbol: "none", | ||
}, | ||
}, | ||
label: { | ||
show: false, | ||
}, | ||
}); | ||
option.series[0].data = chartdata; | ||
|
||
return ( | ||
<EChartsReactCore | ||
echarts={echarts} | ||
option={option} | ||
onChartReady={onChartReady} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
HalfPieChart.propTypes = { | ||
items: PropTypes.array.isRequired, | ||
data: PropTypes.array.isRequired, | ||
onChartReady: PropTypes.func.isRequired, | ||
}; |
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.