通常散點圖的Y軸在左側,X軸的值從0開始,現在X軸的值為負數到正數,比如-30000到30000,中間是0,現在把Y軸通過設定移動到X軸上0這里,但是Y軸刻度上顯示的內容還在默認原來左邊的位置,如圖

我想要的效果如下圖:

代碼如下:
<div id="container10" class="yhgjykt">
<script type="text/javascript">
var dom = document.getElementById("container10");
var myChart = echarts.init(dom);
var app = {};
option = null;
option = {
grid: {
left: "8%",
right:"8%",
bottom:"15%",
top:"11%",
},
xAxis: {
scale: true,
type:"value",
name: "利潤(元)",
nameLocation: "end",
nameTextStyle: {
color: "#28ad98",
align: "left",
verticalAlign: "top",
},
min:-300000,
max:300000,
axisTick: {
show: true,
alignWithLabel: true
},
axisLine: {
onZero: false,
lineStyle: {
color: "#28ad98",
}
},
axisLabel: {
interval:0,
rotate:40, //X軸資料斜著顯示
textStyle: {
color: '#28ad98'
}
},
splitLine: {
show: false,
},
splitNumber: 12,
},
yAxis: {
scale: 0,
type:"value",
data: ['0','1', '2', '3', '4', '5', '6','7'],
axisLine: {
show: true,
onZero: true,
onZeroAxisIndex:0,
lineStyle: {
color: "#28ad98",
},
},
max:'dataMax',
min:0,
interval:1,
axisTick: {
show: false,
},
splitLine: {
show: true,
lineStyle: {
type: "dashed",
color: "#28ad98",
},
},
},
series: [{
itemStyle: {
color: "#0094f8",
},
symbolSize: 10,
data: [
[123600.0, 14],
[117800.0, 13],
[298000.0, 12],
[-200600.0, 11],
[-280000.0, 10],
[-23000.0, 9],
[-29000.0, 8],
[41000.0, 7],
[34000.0, 6],
[26000.0, 5],
[44000.0, 4],
[120000.0, 3],
[57000.0, 2],
[45000.0, 1]
],
type: 'scatter',
symbol: "rect",
itemStyle: {
color: "#d7c74d"
},
emphasis: {
label: {
show: true,
formatter: function (param) {
return param.data[0];
},
position: 'top',
fontSize: 16,
color: "#ffffff"
}
},
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
</script>
請問如何才能實作?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/231394.html
標籤:JavaScript
