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')
  }
};
相关推荐
LYFlied1 天前
WebGPU与浏览器边缘智能:开启去中心化AI新纪元
前端·人工智能·大模型·去中心化·区块链
Setsuna_F_Seiei1 天前
2025 年度总结:人生重要阶段的一年
前端·程序员·年终总结
model20051 天前
alibaba linux3 系统盘网站迁移数据盘
java·服务器·前端
han_1 天前
从一道前端面试题,谈 JS 对象存储特点和运算符执行顺序
前端·javascript·面试
aPurpleBerry1 天前
React 01 目录结构、tsx 语法
前端·react.js
jayaccc1 天前
微前端架构实战全解析
前端·架构
qingyun9891 天前
Web Components 实战:创建自定义比例条组件
前端
前端小超超1 天前
ionic + vue3 + capacitor遇到backButton问题
前端·javascript·vue.js
GIS之路1 天前
GDAL 空间关系解析
前端
布列瑟农的星空1 天前
WebAssembly入门(一)——Emscripten
前端·后端