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')
  }
};
相关推荐
东方小月5 小时前
从零开发一个 Coding Agent(四):使用状态机校验大模型事件流
前端·人工智能·后端
Csvn5 小时前
🧩 ESM vs CJS 混用的 7 个「天坑」——从 TypeScript 编译到 Node 与浏览器
前端
Csvn5 小时前
🎯 Web 性能 API 集合:Performance Observer 的 5 个冷门妙用
前端
Csvn5 小时前
深入 React 闭包陷阱:从根源上理解并根治 stale closure
前端
whyfail6 小时前
前端学 Spring Boot(8):接口为什么越用越慢?
前端·spring boot·后端
用户059540174466 小时前
LangChain 记忆测试踩坑实录:这两个坑让我排查了 4 小时
前端·css
程序员黑豆6 小时前
鸿蒙应用开发:@Monitor 装饰器使用教程
前端·harmonyos
用户938515635076 小时前
从零构建《天龙八部》知识库:EPUB 加载→文本分割→向量嵌入→Milvus 存储→RAG 问答,一条链路打通
javascript·人工智能·全栈
SamChan907 小时前
在Web应用中集成PDF多语言翻译功能:PDFTranslator API实战指南
前端·python·ai·pdf·yapi·机器翻译
kyriewen7 小时前
AI Agent 9秒删光了生产数据库——我给自己的项目做了5个紧急检查
前端·ai编程·claude