131Echarts - 关系图(Calendar Graph)

简介: 131Echarts - 关系图(Calendar Graph)
效果图

源代码
 <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <!-- 引入 echarts.js -->
    <script src="js/echarts.min.js"></script>
    <script src="js/jquery-1.11.0.min.js"></script>
    <script src="dist/extension/dataTool.js"></script>
  </head>
  <body>
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
      // 基于准备好的dom,初始化echarts实例
      var myChart = echarts.init(document.getElementById('main'));
      var option;
      var graphData = [
        [
          1485878400000,
          260
        ],
        [
          1486137600000,
          200
        ],
        [
          1486569600000,
          279
        ],
        [
          1486915200000,
          847
        ],
        [
          1487347200000,
          241
        ],
        [
          1487779200000 + 3600 * 24 * 1000 * 15,
          411
        ],
        [
          1488124800000 + 3600 * 24 * 1000 * 23,
          985
        ]
      ];
      var links = graphData.map(function(item, idx) {
        return {
          source: idx,
          target: idx + 1
        };
      });
      links.pop();
      function getVirtulData(year) {
        year = year || '2017';
        var date = +echarts.number.parseDate(year + '-01-01');
        var end = +echarts.number.parseDate((+year + 1) + '-01-01');
        var dayTime = 3600 * 24 * 1000;
        var data = [];
        for(var time = date; time < end; time += dayTime) {
          data.push([
            echarts.format.formatTime('yyyy-MM-dd', time),
            Math.floor(Math.random() * 1000)
          ]);
        }
        return data;
      }
      option = {
        tooltip: {},
        calendar: {
          top: 'middle',
          left: 'center',
          orient: 'vertical',
          cellSize: 40,
          yearLabel: {
            margin: 50,
            textStyle: {
              fontSize: 30
            }
          },
          dayLabel: {
            firstDay: 1,
            nameMap: 'cn'
          },
          monthLabel: {
            nameMap: 'cn',
            margin: 15,
            textStyle: {
              fontSize: 20,
              color: '#999'
            }
          },
          range: ['2017-02', '2017-03-31']
        },
        visualMap: {
          min: 0,
          max: 1000,
          type: 'piecewise',
          left: 'center',
          bottom: 20,
          inRange: {
            color: ['#5291FF', '#C7DBFF']
          },
          seriesIndex: [1],
          orient: 'horizontal'
        },
        series: [{
          type: 'graph',
          edgeSymbol: ['none', 'arrow'],
          coordinateSystem: 'calendar',
          links: links,
          symbolSize: 15,
          calendarIndex: 0,
          itemStyle: {
            normal: {
              color: 'yellow',
              shadowBlue: 9,
              shadowOffsetX: 1.5,
              shadowOffsetY: 3,
              shadowColor: '#555'
            }
          },
          lineStyle: {
            normal: {
              color: '#D10E00',
              width: 1,
              opacity: 1
            }
          },
          data: graphData,
          z: 20
        }, {
          type: 'heatmap',
          coordinateSystem: 'calendar',
          data: getVirtulData(2017)
        }]
      };
      myChart.setOption(option);
    </script>
  </body>
</html>
目录
相关文章
|
7月前
|
JavaScript
echarts_自定义graph关系图
echarts_自定义graph关系图
141 0
|
JSON 数据格式
echarts关系图
echarts关系图
81 0
269Echarts - GL 关系图(1w 节点 2w7 边的NPM 依赖图)
269Echarts - GL 关系图(1w 节点 2w7 边的NPM 依赖图)
97 0
268Echarts - GL 关系图(GraphGL - Large Internet)
268Echarts - GL 关系图(GraphGL - Large Internet)
125 0
|
异构计算
267Echarts - GL 关系图(GraphGL GPU Layout)
267Echarts - GL 关系图(GraphGL GPU Layout)
102 0
192Echarts - 自定义系列(Custom Calendar Icon)
192Echarts - 自定义系列(Custom Calendar Icon)
39 0
189Echarts - 日历坐标系(Custom Calendar Icon)
189Echarts - 日历坐标系(Custom Calendar Icon)
52 0
188Echarts - 日历坐标系(Calendar Heatmap Vertical)
188Echarts - 日历坐标系(Calendar Heatmap Vertical)
44 0
187Echarts - 日历坐标系(Simple Calendar)
187Echarts - 日历坐标系(Simple Calendar)
35 0
186Echarts - 日历坐标系(Calendar Pie)
186Echarts - 日历坐标系(Calendar Pie)
47 0

热门文章

最新文章

下一篇
DataWorks