JS 变换数据

<html>
<head>
<meta charset="utf-8">
<title>JS 变换数据</title>
</head>
<body>
	
<script>

var A = [1, 2,3,1];
var B = [4, 5, 6,7];

function generateData() {
  let data = [];
  for (let i = 0; i <= A.length; i++) {
    data.push(A[i],B[i]);
  }
  return data;
}
document.write(generateData());
</script>
	
</body>
</html>

 

let xData = [];
let yData = [];
for (let i = 0; i < 10; i++) {
  xData.push(i);
  yData.push(i);
}
function generateData() {
  let data = [];
  for (let i = 0; i < 100; i++) {
    data.push([${x}[i],${y}[i],${T}[i]]);
  }
  return data;
}
let data = generateData();
option = {
  tooltip: {},
  xAxis: {
    type: 'category',
    data: xData
  },
  yAxis: {
    type: 'category',
    data: yData
  },
  visualMap: {
    type: 'piecewise',
    splitNumber: 8,
    min: 0,
    max: 100,
    calculable: true,
    realtime: false,
    orient: 'horizontal',
    left:'center',
    inRange: {
      color: [
        '#313395',
        '#4575b4',
        '#74add1',
        '#abd9e9',
        '#e0f3f8',
        '#ffffbf',
        '#fee090',
        '#fdae61',
        '#f46d43',
        '#d73027',
        '#a50026'
      ]
    }
  },
  series: [
    {
      name: 'Gaussian',
      type: 'heatmap',
      data: data,
      emphasis: {
        itemStyle: {
          borderColor: '#333',
          borderWidth: 1
        }
      },
      progressive: 5000,
      animation: true
    }
  ]
};

 

posted @ 2022-06-24 10:33  华小电  阅读(30)  评论(0编辑  收藏  举报