I want to add several vertical marklines to a line chart and allow users to do horizontal dragging, similar to this Highcharts example.
Setting xAxis.axisPointer
is useful in this sense. However, how can I allow the whole vertical line to be dragged on the horizontal line, rather than using the button at the botton as shown below ?
import "./styles.css";
import echarts from "echarts";
const myChart = echarts.init(document.getElementById("app"));
const option = {
xAxis: {
type: "time",
nameLocation: "center",
nameGap: 20,
interval: 420000,
min: 1625741884000,
max: 1625749084000,
axisLabel: {
rotate: 0
},
boundaryGap: ["0%", "0%"],
axisPointer: {
value: 1625742000000,
snap: true,
lineStyle: {
color: "#ff0000",
width: 4
},
handle: {
show: true,
color: "#ff0000"
}
}
},
yAxis: [
{
type: "value",
nameLocation: "center",
nameGap: 8,
interval: 0.33,
min: 1,
max: 5.33,
axisLabel: {
margin: 24,
rotate: 0
}
}
],
series: [
{
id: "test",
name: "Average Time",
yAxisIndex: 0,
data: [
{
value: [1625741884000, 1]
},
{
value: [1625741885000, 1]
},
{
value: [1625741890000, 1]
},
...
],
subSeries: [],
invert: false,
type: "line",
showSymbol: false,
symbolSize: 5,
smooth: false,
color: "#4da6e8",
lineStyle: {}
}
]
};
myChart.setOption(option);