/app/assets/javascripts/chart_templates.js

https://github.com/johannchen/profiles · JavaScript · 132 lines · 122 code · 2 blank · 8 comment · 0 complexity · 96a1be2e1425fcddb087a176593e1c4c MD5 · raw file

  1. $.elycharts.templates['analytics'] = {
  2. type: "line",
  3. //margins: [10, 15, 25, 15],
  4. margins: [15, 15, 15, 15],
  5. /* Define how to draw tooltips starting from series data */
  6. /* this can be an array with the tooltips content or a function to generate them on the fly */
  7. //tooltips: function(env, serie, index, value, label) {
  8. ////return "<div class='label'><p class='date'>September " + index + "</p><p><span class='visits'>Visits:</span> " + env.opt.values['serie1'][index] + "</p><p><span class='hits'>Hits:</span> " + env.opt.values['serie2'][index] + "</p></div>";
  9. //return "<div class='label'><p class='date'>September " + index + "</p><p><span class='visits'>Visits:</span> " + env.opt.values['serie1'][index] + "</p></div>";
  10. //},
  11. defaultSeries: {
  12. plotProps: {
  13. "stroke-width": 4
  14. },
  15. dot: true,
  16. rounded: false,
  17. dotProps: {
  18. stroke: "white",
  19. size: 5,
  20. "stroke-width": 1,
  21. opacity: 0 // dots invisible until we hover it
  22. },
  23. startAnimation: { // use an animation to start plotting the chart
  24. active: false,
  25. type: "avg", // start from the average line.
  26. speed: 1000, // animate in 1 second.
  27. easing: ">"
  28. },
  29. stepAnimation: { // defines an animation for data updates
  30. speed: 2000,
  31. delay: 0,
  32. easing: '<>'
  33. },
  34. highlight: {
  35. scaleSpeed: 0, // do not animate the dot scaling. instant grow.
  36. scaleEasing: '',
  37. scale: 1.2, // enlarge the dot on hover
  38. newProps: {
  39. opacity: 1 // show dots on hover
  40. }
  41. },
  42. tooltip: {
  43. height: 45,
  44. width: 80,
  45. padding: [3, 3],
  46. offset: [-15, -10],
  47. frameProps: {
  48. opacity: 0.95,
  49. /* fill: "white", */
  50. stroke: "#000"
  51. }
  52. }
  53. },
  54. series: {
  55. serie1: {
  56. fill: true,
  57. fillProps: {
  58. opacity: .1
  59. },
  60. color: "#26B",
  61. },
  62. serie2: {
  63. axis: 'r',
  64. color: "#F80",
  65. plotProps: {
  66. "stroke-width": 2
  67. },
  68. dotProps: {
  69. stroke: "white",
  70. size: 3,
  71. "stroke-width": 1
  72. }
  73. }
  74. },
  75. defaultAxis: {
  76. labels: true,
  77. labelsProps: {
  78. fill: "#49B",
  79. "font-size": "10px"
  80. },
  81. labelsAnchor: "start",
  82. labelsMargin: 5,
  83. labelsDistance: -8
  84. },
  85. axis: {
  86. l: { // left axis
  87. labels: true,
  88. labelsDistance: 0,
  89. labelsSkip: 1,
  90. labelsAnchor: "start",
  91. labelsMargin: 15,
  92. labelsProps: {
  93. fill: "#AAA",
  94. "font-size": "11px",
  95. "font-weight": "bold"
  96. }
  97. },
  98. r: { // right axis
  99. labels: true,
  100. labelsDistance: 0,
  101. labelsSkip: 1,
  102. labelsAnchor: "end",
  103. labelsMargin: 15,
  104. labelsProps: {
  105. fill: "#AAA",
  106. "font-size": "11px",
  107. "font-weight": "bold"
  108. }
  109. }
  110. },
  111. features: {
  112. mousearea: {
  113. type: 'axis'
  114. },
  115. tooltip: {
  116. positionHandler: function(env, tooltipConf, mouseAreaData, suggestedX, suggestedY) {
  117. return [mouseAreaData.event.pageX, mouseAreaData.event.pageY, true]
  118. }
  119. },
  120. grid: {
  121. draw: true, // draw both x and y grids
  122. forceBorder: [true, false, true, false], // force grid for external border
  123. ny: 2, // use 10 divisions for y grid
  124. nx: 5, // 10 divisions for x grid
  125. props: {
  126. stroke: "#CCC" // color for the grid
  127. }
  128. }
  129. }
  130. }