|
@@ -11,6 +11,7 @@ class LineChart extends React.Component {
|
|
|
|
|
|
componentDidMount() {
|
|
|
this.initChart();
|
|
|
+ window.addEventListener("resize", this.chartResize);
|
|
|
}
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
@@ -19,10 +20,17 @@ class LineChart extends React.Component {
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
if (this.chartInstance) {
|
|
|
+ window.removeEventListener("resize", this.chartResize);
|
|
|
this.chartInstance.dispose();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ chartResize() {
|
|
|
+ if (this.chartInstance) {
|
|
|
+ this.chartInstance.resize();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
initChart() {
|
|
|
if (!this.chartInstance) {
|
|
|
this.chartInstance = echarts.init(this.chartRef.current);
|
|
@@ -33,7 +41,7 @@ class LineChart extends React.Component {
|
|
|
legend: {
|
|
|
top: 10,
|
|
|
itemGap: 30,
|
|
|
- textStyle: { color: "#fff" },
|
|
|
+ textStyle: { color: "#fff", fontSize: '20px' },
|
|
|
data: this.props.legendData,
|
|
|
},
|
|
|
grid: {
|
|
@@ -46,7 +54,7 @@ class LineChart extends React.Component {
|
|
|
type: "category",
|
|
|
boundaryGap: true,
|
|
|
axisLine: { lineStyle: { color: "#666" } },
|
|
|
- axisLabel: { color: "#fff" },
|
|
|
+ axisLabel: { color: "#fff", fontSize: '16px' },
|
|
|
splitLine: {
|
|
|
// x 轴竖直方向虚线
|
|
|
show: true,
|
|
@@ -60,7 +68,7 @@ class LineChart extends React.Component {
|
|
|
yAxis: {
|
|
|
type: "value",
|
|
|
axisLine: { show: false },
|
|
|
- axisLabel: { color: "#fff" },
|
|
|
+ axisLabel: { color: "#fff", fontSize: '16px' },
|
|
|
splitLine: {
|
|
|
// y 轴竖直方向虚线
|
|
|
show: true,
|
|
@@ -72,7 +80,6 @@ class LineChart extends React.Component {
|
|
|
},
|
|
|
series: this.props.seriesData,
|
|
|
};
|
|
|
- console.log("option", option);
|
|
|
this.chartInstance.setOption(option);
|
|
|
}
|
|
|
|