Advertisement
Guest User

echart issue with connect

a guest
Aug 30th, 2019
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * example showing the issue with connect and legend
  3.  */
  4.  
  5.  let initGraphs = () => {
  6.      let x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  7.      let y1 = [], y2 = [], y3 = [], y4 = [], y5 = [], y6=[];
  8.      let max = 2;
  9.      let min = -2;
  10.      for (i = 0; i<=10; i++){
  11.          y1.push(Math.random() * (+max - +min) + +min)
  12.          y2.push(Math.random() * (+max - +min) + +min)
  13.          y3.push(Math.random() * (+max - +min) + +min)
  14.          y4.push(Math.random() * (+max - +min) + +min)
  15.          y5.push(Math.random() * (+max - +min) + +min)
  16.          y6.push(Math.random() * (+max - +min) + +min)
  17.      }
  18.      
  19.      let options = {
  20.         legend: {
  21.             data: ["A", "B", "C"],
  22.             top: '17%',
  23.           },
  24.         xAxis: {
  25.             type: 'value',
  26.             data: x
  27.         },
  28.         yAxis: {
  29.             type: 'value'
  30.         },
  31.         series: [{
  32.             name: "A",
  33.             data: y1,
  34.             type: 'line',
  35.             smooth: true
  36.         },
  37.         {
  38.             name: "B",
  39.             data: y2,
  40.             type: 'line',
  41.             smooth: true
  42.         },{
  43.             name: "C",
  44.             data: y3,
  45.             type: 'line',
  46.             smooth: true
  47.         },],
  48.         tooltip: {
  49.             trigger: "axis",
  50.             showDelay: 0,
  51.         }
  52.      }
  53.      let options2 = {
  54.        
  55.         xAxis: {
  56.             type: 'value',
  57.             data: x
  58.         },
  59.         yAxis: {
  60.             type: 'value'
  61.         },
  62.         series: [{
  63.             name: "C",
  64.             data: y3,
  65.             type: 'line',
  66.             smooth: true
  67.         }],
  68.         tooltip: {
  69.             trigger: "axis",
  70.             showDelay: 0,
  71.         }
  72.      }
  73.      let options3 = {
  74.         legend: {
  75.             data: ["E", "F"],
  76.             top: '17%',
  77.           },
  78.         xAxis: {
  79.             type: 'value',
  80.             data: x
  81.         },
  82.         yAxis: {
  83.             type: 'value'
  84.         },
  85.         series: [{
  86.             name: "E",
  87.             data: y5,
  88.             type: 'line',
  89.             smooth: true
  90.         },
  91.         {
  92.             name: "F",
  93.             data: y6,
  94.             type: 'line',
  95.             smooth: true
  96.         }],
  97.         tooltip: {
  98.             trigger: "axis",
  99.             showDelay: 0,
  100.         }
  101.      }
  102.      let chart1 = echarts.init(document.getElementById("graph1"));
  103.      chart1.setOption(options);
  104.      let chart2 = echarts.init(document.getElementById("graph2"));
  105.      chart2.setOption(options2);
  106.      let chart3 = echarts.init(document.getElementById("graph3"));
  107.      chart3.setOption(options3);
  108.      
  109.      echarts.connect([chart1, chart2, chart3])
  110.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement