• 数据展示时间线展示工具Timeline


    每日一贴,今天的内容关键字为数据展示

        时光线展示工具Timeline[1],可以实现网页上展示一个时光轴。在时光相关的数据展示中,有比较好的效果。测试了下,详细的用法是这样的。

        

    1.编写html页面,引入JS脚本,引入JSON数据,设定待表现日历位置

        <scriptsrc="http://static.simile.mit.edu/timeline/api-2.3.0/timeline-api.js?bundle=true"type="text/javascript"></script>

        <scriptsrc="local_data2.js" type="text/javascript"></script>

        <divid='tl'></div>

        

    2.编写加载函数,并在网页中调用该函数

        <script>       

            var tl;

            function onLoad() {

                var tl_el =document.getElementById("tl");

                var eventSource1 = newTimeline.DefaultEventSource();

               

                var theme1 =Timeline.ClassicTheme.create();

                theme1.autoWidth = true; // Set theTimeline's "width" automatically.

                                         // SetautoWidth on the Timeline's first band's theme,

                                         // willaffect all bands.

                theme1.timeline_start = newDate(Date.UTC(1980, 0, 1));

                theme1.timeline_stop  = new Date(Date.UTC(2150, 0, 1));

               

                var d =Timeline.DateTime.parseGregorianDateTime("1980")

                var bandInfos = [

                    Timeline.createBandInfo({

                                  45, // set to a minimum, autoWidthwill then adjust

                        intervalUnit:   Timeline.DateTime.DECADE,

                        intervalPixels: 200,

                        eventSource:    eventSource1,

                        date:           d,

                        theme:          theme1,

                        layout:         'original'  // original, overview, detailed

                    })

                ];

                                                               

                // create the Timeline

                tl = Timeline.create(tl_el,bandInfos, Timeline.HORIZONTAL);

               

                var url = '.'; // The base url forimage, icon and background image

                               // references in thedata

               eventSource1.loadJSON(timeline_data, url); // The data was stored intothe

        每日一道理
    书,各种各样的书。书,寄托着人类热切的希望;书,蕴含着人类丰富的感悟。提起书,会有说不完的话语……

                                                          // timeline_data variable.

                tl.layout(); // display theTimeline

            }

           

            var resizeTimerID = null;

            function onResize() {

                if (resizeTimerID == null) {

                    resizeTimerID =window.setTimeout(function() {

                        resizeTimerID = null;

                        tl.layout();

                    }, 500);

                }

            }

       </script>

        调用该函数:<body onload="onLoad();"onresize="onResize();">

        

    3.编写包括事件的JSON文件

        vartimeline_data = {  // save as a globalvariable

        'dateTimeFormat':'iso8601',

        'wikiURL':"http://simile.mit.edu/shelf/",

        'wikiSection':"Simile Cubism Timeline",

        'events' : [

             {'start': '1987',

            'title': 'Birthday of gongqingkui',

            'description': 'This is description',

            'image':'http://portrait7.sinaimg.cn/1150968582/blog/180',

            'link':'http://blog.sina.com.cn/gongqingkui',

             'icon' :"dark-red-circle.png",       

            'color' : 'red',

            'textColor' : 'green'

            },

             {'start':'1986',

             'end':'1990',

             'isDuration':true,

             'title':'aaa',

             //'tapeImage': 'blue_stripes.png',

            'tapeRepeat': 'repeat-x',

            'caption': "This is the event'scaption attribute.",

            'classname': 'hot_event'         

             },

        ]

        }

        该JSON数据目前包括一个点事件和一个段时光。

        4.加载效果

        数据和展示

        这是最简略的使用方法,一些详细的例子在这里http://simile-widgets.org/timeline/examples/index.html。与这个相似的一个应用timeplot[2]可以画时光相关的数据直方图,效果如下。

        数据和展示 

        参考

        1.Timeline项目主页http://simile-widgets.org/timeline/

        2.Timeplot项目主页http://simile-widgets.org/timeplot/

    文章结束给大家分享下程序员的一些笑话语录: 联想——对内高价,补贴对外倾销的伟大“民族”企业。

  • 相关阅读:
    闲谈《一》
    GoldenGate系列一:快速搭建单向同步GoldenGate环境
    读取并分析wgetrc文件
    oracle之Flash Recovery Area全面介绍
    使用Subversion进行版本控制 附录A
    使用lstat()判断文件类型
    连接数据库时提示归档器失败 ORA00257: archiver error
    GoldenGate系统三:trouble shooting and log
    关于VMware虚拟机的上网
    使用C语言读取properties文件V1.0
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3080582.html
Copyright © 2020-2023  润新知