2 回答
TA贡献1845条经验 获得超8个赞
var myChart = echarts.init(document.getElementById('main'));
var option = {
xAxis: [{
data: ["1", "2", "3", "4", "5", "6"]
},{
data: ["1", "2", "3", "4", "5", "6"],
show: false,
}],
yAxis: {},
series: [
{
name: 'Series1',
type: 'bar',
data: [5, 20, 36, 10, 10, 20],
markLine: {
data: [{
symbol: 'none',
name: 'max line',
type: 'max',
lineStyle: {
normal: {
type:'solid',
color: 'blue',
}
},
}],
}
},{
name: 'Series2',
type: 'bar',
data: [0,0],
xAxisIndex: 1,
label: { show: false },
markLine: {
symbol: 'none',
data: [{
yAxis: 24,
label: {
normal: {
show: false,
}
},
lineStyle: {
normal: {
type:'dashed',
color: 'green',
}
},
}],
}
}]
}
myChart.setOption(option);
<div id="main" style="width: 600px;height:600px;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.6.2/echarts.min.js"></script>
TA贡献1801条经验 获得超8个赞
将符号设置为数组,当您在当前图形上获取选项时显示默认值let currentOptions = graph.getoption();
,然后currentOptions.markLine
是显示默认值的对象,因此要覆盖默认值,请在系列上使用此选项。
let setPointSeriesObject = {
name: "Setpoints",
type: 'line',
xAxisIndex: 0,
yAxisIndex: 0,
markLine: {
symbol:["none","none"],
data: setPointLines,
emphasis:{
label: {
show:false
},
lineStyle:{
width:1
}
},
tooltip:{
trigger:"none"
}
}
};
options.series.push(setPointSeriesObject);
为了完整起见,我的代码有一组设置点,通常是最小和最大公差。这是创建 setPointLines 的代码
let graphSetPointLinesFixed = [10,-10] //max and min tolerances line
let setPointLines = [];
for (const setPoint of graphSetPointLinesFixed) {
setPointLines.push({
name:parseFloat(setPoint),
yAxis:parseFloat(setPoint)
});
}
总的来说,此代码创建了可以打开和关闭的设定点,如图所示。我不知道这是什么时候成为设置 markLines 的方法,但它适用于 5.3 和 5.4。
TA贡献1946条经验 获得超4个赞
您的符号声明有误,请执行以下操作:
markLine: {
symbol: 'icon' // <---- it's wrong
data: [{
symbol: 'diamond', // <---- it's right
symbolSize: 30,
name: 'average line',
type: 'average'
},{
symbol: 'circle',
symbolSize: 30,
name: 'max line',
type: 'max'
}]
}
var myChart = echarts.init(document.getElementById('main'));
// Unsert your code below
var option = {
xAxis: {
data: ["1", "2", "3", "4", "5", "6"]
},
yAxis: {},
series: [{
name: 'Series1',
stack: '1',
type: 'bar',
data: [5, 20, 36, 10, 10, 20],
markLine: {
data: [{
symbol: 'diamond',
symbolSize: 30,
name: 'average line',
type: 'average'
},{
symbol: 'circle',
symbolSize: 30,
name: 'max line',
type: 'max'
}]
}
}]
}
myChart.setOption(option);
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.6.2/echarts.min.js"></script>
<div id="main" style="width: 600px;height:400px;"></div>
添加回答
举报