HTML5画布MeteorCharts折线图

创建一个HTML5画布与MeteorCharts折线图,我们可以实例化一个MeteorCharts。行对象容器DOM元素,一个模型配置,和一个视图配置。模型配置包含所有数据的图表,如标题和系列,和视图包含所有的样式,如图表大小、背景颜色和文本颜色。

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.4.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js"></script>
    <script src="http://d3lp1msu2r81bx.cloudfront.net/mc/js/lib/meteorcharts-v0.0.11.min.js"></script>
    <script defer="defer"> 
      var secondsInYear = 60 * 60 * 24 * 365;
      
      // model configuration (data)
      var model = {
        title: 'Example Chart', 
        series: [{
          title: 'Line 1',
          points: [
            {x: secondsInYear * 0, y: 7.0},
            {x: secondsInYear * 1, y: 6.9},
            {x: secondsInYear * 2, y: 9.5},
            {x: secondsInYear * 3, y: 14.5},
            {x: secondsInYear * 4, y: 18.2},
            {x: secondsInYear * 5, y: 21.5},
            {x: secondsInYear * 6, y: 25.2},
            {x: secondsInYear * 7, y: 26.5},
            {x: secondsInYear * 8, y: 23.3},
            {x: secondsInYear * 9, y: 18.3},
            {x: secondsInYear * 10, y: 13.9},
            {x: secondsInYear * 11, y: 9.6}
          ] 
        },
        {
          title: 'Line 2',
          points: [
            {x: secondsInYear * 0, y: -0.2},
            {x: secondsInYear * 1, y: 0.8}, 
            {x: secondsInYear * 2, y: 5.7},
            {x: secondsInYear * 3, y: 11.3},
            {x: secondsInYear * 4, y: 17.0},
            {x: secondsInYear * 5, y: 22.0},
            {x: secondsInYear * 6, y: 24.8},
            {x: secondsInYear * 7, y: 24.1},
            {x: secondsInYear * 8, y: 20.1},
            {x: secondsInYear * 9, y: 14.1},
            {x: secondsInYear * 10, y: 8.6},
            {x: secondsInYear * 11, y: 2.5}
          ] 
        }]
      };
      
      // view configuration (styling)
      var view = {
        width: 580,
        height: 300
      };

      // line charts are instantiated with a container DOM element,
      // a model, and a view
      var lineChart = new MeteorCharts.Line({
        container: 'container',
        model: model,
        view: view
      });
    </script>
  </body>
</html>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值