项目作者: evoluteur

项目描述 :
Table/Cards views using D3.js for animated transitions on sorting and changing view.
高级语言: JavaScript
项目地址: git://github.com/evoluteur/d3-table-cards.git
创建时间: 2017-04-12T00:58:44Z
项目社区:https://github.com/evoluteur/d3-table-cards

开源协议:MIT License

下载


D3-Table-Cards · GitHub license npm version

Example of using D3.js for transformations between table and cards views, and animated transitions while sorting elements or resizing the browser.

Check out the demo.

screenshot

This code uses HTML (with absolute positioning) rather than SVG, and has no dependencies beside D3.js.

The table and cards layouts are configurable.

  1. const layoutInfo = {
  2. table: {
  3. // row position & size
  4. top: (d, i) => 40+i*31+"px",
  5. left: "0px",
  6. height: "30px",
  7. width: "594px",
  8. // row border-radius
  9. radius: 0,
  10. // table header
  11. headerOpacity: 1,
  12. headerLeft: "0px",
  13. // column 1
  14. c1Top: "5px",
  15. c1Left: "8px",
  16. c1FontSize: "16px",
  17. // column 2
  18. c2Top: "5px",
  19. c2Left: "200px",
  20. },
  21. cards: {
  22. // card position & size
  23. top: (d, i) => Math.floor(i/cardsPerRow)*94+"px",
  24. left: (d, i) => (i%cardsPerRow)*210+"px",
  25. height: "84px",
  26. width: "200px",
  27. // card border-radius
  28. radius: "4px",
  29. // table header (hidden)
  30. headerOpacity: 0,
  31. headerLeft: "-650px",
  32. // line 1
  33. c1Top: "10px",
  34. c1Left: "10px",
  35. c1FontSize: "18px",
  36. // line 2
  37. c2Top: "38px",
  38. c2Left: "10px",
  39. }
  40. };

Note: The same result can also be achieved using CSS transitions instead of D3.

My other D3 animations: meet-the-fans and d3-dual-range-slider.

(c) 2024 Olivier Giulieri