+
${raw.time}
+
+ 收盘
+ ${raw.close?.toFixed(2)}
+
+
+ 涨跌
+ ${sign}${changePct.toFixed(2)}%
+
+
+ `;
+ }
+ },
+ xAxis: [
+ { type: 'category', data: chartData.dates, gridIndex: 0, show: false, boundaryGap: true },
+ { type: 'category', data: chartData.dates, gridIndex: 1, show: false, boundaryGap: true }
+ ],
+ yAxis: [
+ { type: 'value', gridIndex: 0, show: false, scale: true },
+ { type: 'value', gridIndex: 1, show: false, scale: true }
+ ],
+ dataZoom: [{
+ type: 'inside',
+ xAxisIndex: [0, 1],
+ start: 30,
+ end: 100,
+ zoomOnMouseWheel: true,
+ moveOnMouseMove: true
+ }],
+ series: [
+ {
+ name: 'K线',
+ type: 'candlestick',
+ data: chartData.klineData,
+ xAxisIndex: 0,
+ yAxisIndex: 0,
+ itemStyle: {
+ color: UP_COLOR,
+ color0: DOWN_COLOR,
+ borderColor: UP_COLOR,
+ borderColor0: DOWN_COLOR,
+ borderWidth: 1
+ },
+ barWidth: '70%'
+ },
+ {
+ name: '成交量',
+ type: 'bar',
+ data: chartData.volumes,
+ xAxisIndex: 1,
+ yAxisIndex: 1,
+ itemStyle: {
+ color: (params) => {
+ const idx = params.dataIndex;
+ const raw = chartData.rawData[idx];
+ return raw && raw.close >= raw.open ? 'rgba(239,83,80,0.4)' : 'rgba(38,166,154,0.4)';
+ }
+ },
+ barWidth: '70%'
+ }
+ ]
+ };
+ }, [chartData]);
+
+ if (loading) {
+ return (
+