ECharts 日历坐标示例

javascript 复制代码
function getVirtualData(year) {
  const date = +echarts.time.parse(year + '-01-01');
  const end = +echarts.time.parse(+year + 1 + '-01-01');
  const dayTime = 3600 * 24 * 1000;
  const data = [];
  for (let time = date; time < end; time += dayTime) {
    data.push([
      echarts.time.format(time, '{yyyy}-{MM}-{dd}', false),
      Math.floor(Math.random() * 10000)
    ]);
  }
  return data;
}
option = {
  title: {
    top: 30,
    left: 'center',
    text: 'Daily Step Count'
  },
  tooltip: {},
  visualMap: {
    min: 0,
    max: 10000,
    type: 'piecewise',
    orient: 'horizontal',
    left: 'center',
    top: 65,
    color:[
      '#d16ba5', 
      '#c777b9', 
      '#ba83ca', 
      '#aa8fd8', 
      '#9a9ae1', 
      '#8aa7ec', 
      '#79b3f4', 
      '#69bff8', 
      '#52cffe', 
      '#41dfff', 
      '#46eefa', 
      '#5ffbf1'],
  },
  calendar: {
    top: 120,
    left: 30,
    //right: 30,
    cellSize: [16, 16],
    range: ['2017-01-01', '2017-01-31'],
    itemStyle: {
      borderWidth: 0.1,
      //borderColor:'yellow',
      borderWidth:2,
    },
    yearLabel: { show: true },
    monthLabel:{show:true},
    dayLabel:{
      show:true,
      firstDay:3,
      
    }
  },
  series: {
    type: 'heatmap',
    coordinateSystem: 'calendar',
    data: getVirtualData('2017')
  }
};
相关推荐
赖龙6 小时前
pnpm vs npm
前端·npm·node.js
To_OC7 小时前
LC 239 滑动窗口最大值:从暴力超时到单调队列一遍过
javascript·算法·leetcode
学如逆水,不进则退7 小时前
在线免费音频剪辑:NBTools 可视化波形裁剪 MP3/WAV,本地处理免上传
前端·音视频
Mh8 小时前
虚拟滚动真的比普通滚动性能更好吗?
前端·javascript·性能优化
pe7er8 小时前
React + Ant Design 中的 IME (输入法合成)安全输入组件
前端
Super 含8 小时前
Android 启动优化(二):TTID、TTFD 与 Macrobenchmark 启动性能测量
前端
Python私教8 小时前
别急着加 llms.txt:企业官网面向 AI 搜索的工程清单
前端·人工智能·seo
东方小月9 小时前
从零开发一个 Coding Agent(十三):实现安全的 read 文件读取工具
前端·人工智能·全栈
东方小月9 小时前
从零开发一个 Coding Agent(十二):实现版本化 JSONL 与真实 CLI 入口
前端·设计模式·前端框架
Smile_ping10 小时前
ECharts 图例文本对齐,告别长短不一!
echarts·legend·图例文本对齐