Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. [ entityA : [ { time : 1230000, // time since epoch
  2. attribute1 : 123 // numeric value
  3. attribute2 : 123 // numeric value
  4. },
  5. { time : 1230010, // time since epoch
  6. attribute1 : 123 // numeric value
  7. attribute2 : 123 // numeric value
  8. } ],
  9. entityB : [ { ... // same format as above
  10. ...
  11. ]
  12.  
  13. var line = d3.svg.line()
  14. .x(function(d) {
  15. return x_scale(d.c_date));
  16. })
  17. .y(function(d) {
  18. return y_scale(d.total);
  19. });
  20.  
  21. canvas.append("svg:path")
  22. .attr("d", line(data[entity]))
  23.  
  24. var width = 400;
  25. var height = 400;
  26.  
  27. var svg = d3.select('body')
  28. .append('svg')
  29. .attr('width', width)
  30. .attr('height', height);
  31.  
  32.  
  33. //The data for our line
  34. var lineData = [{
  35. "x": 1,
  36. "y": 5
  37. },
  38. {
  39. "x": 20,
  40. "y": 20
  41. },
  42. {
  43. "x": 40,
  44. "y": 10
  45. },
  46. {
  47. "x": 60,
  48. "y": 40
  49. },
  50. {
  51. "x": 80,
  52. "y": 5
  53. },
  54. {
  55. "x": 100,
  56. "y": 60
  57. }
  58. ];
  59.  
  60. //The line SVG Path we draw
  61. var lineGraph = svg.append("path")
  62. .attr("d", d3.line()
  63. .x(d => d.x)
  64. .y(d => d.y)
  65. .curve(d3.curveLinear)(lineData))
  66. //.curve(d3.curveBasis)(lineData)) //Draws smooth joints- yumuşak birleşim noktası(mafsal) çizer
  67. .attr("stroke", "blue")
  68. .attr("stroke-width", 2)
  69. .attr("fill", "none");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement