项目作者: zhangyu94

项目描述 :
Reusable multi-resolution timeseries layout plugin for d3
高级语言: JavaScript
项目地址: git://github.com/zhangyu94/d3-timeseries.git
创建时间: 2016-08-19T08:51:45Z
项目社区:https://github.com/zhangyu94/d3-timeseries

开源协议:MIT License

下载


d3-timeseries

D3 3.0 implementation of timeseries plugin that supports easy customization of bitmap / horizongraph / linechart or multiresolution layout self adaptive to display height.

The plugin is implemented as a closure that support method chaining.

Installing

Dependency: D3-timeseries requires D3 3.x version and jquery as dependency
Installing: All the content of d3-timeseries plugin is in the folder libs/d3_timeseries. To use bitmap or horizon or linechart, you can just download the corresponding single file (and corresponding css, if it has) in the folder. Two different versions of linechart are provided that share the same css file.

How to render a line chart

Step1. Binding: use jquery to select a div, and bind a d3_linechart object to it with $(“#”+divID).d3_linechart()

Step2. Style specification: customize it with method chaining, such as $(“#”+divID).d3_linechart().height(200).data(data)

Step3. Render: Evoke ($(“#”+divID).d3_linechart().render())() to get the chart rendered. Another option is to use d3_linechart = $(“#”+divID).d3_linechart() to get the renderer, and render the chart yourself with svg.datum(data).call(d3_linechart)

Usage example

  1. var linechart = [{
  2. label: "Data Set 1",
  3. data: [
  4. {x:0,y:0},
  5. {x:1,y:1,color:"red"},
  6. {x:2,y:2,color:"red"},
  7. {x:3,y:-3},
  8. {x:4,y:4,color:"red"},
  9. {x:5,y:17},
  10. {x:6,y:3},
  11. {x:7,y:3}
  12. ]
  13. }]
  14. var renderer = $("#"+divID).d3_linechart()
  15. .data([linechart])
  16. .x_scale_type("linear")
  17. .draw_xgrid(true)
  18. .draw_ygrid(true)
  19. .margin({top: 20, right: 80, bottom:20, left: 40})
  20. .render()
  21. renderer()

Credits

The Horizon Graph layout is credit to the layout in https://bl.ocks.org/mbostock/1483226