• Edit
  • Download
    1. <!DOCTYPE html>
    2. <html>
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingSoft Demo</title>
    7.  
    8. <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
    9. <style>
    10. html,
    11. body {
    12. height: 100%;
    13. width: 100%;
    14. margin: 0;
    15. padding: 0;
    16. }
    17.  
    18. #myChart {
    19. height: 100%;
    20. width: 100%;
    21. min-height: 150px;
    22. }
    23.  
    24. .zc-ref {
    25. display: none;
    26. }
    27. </style>
    28. </head>
    29.  
    30. <body>
    31. <div id="myChart"><a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a></div>
    32. <script>
    33. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; // Global wrapper
    34. window.customFncs = {};
    35.  
    36. var myConfig = {
    37. type: "line",
    38. title: {
    39. text: 'jsRule Demo'
    40. },
    41. tooltip: {
    42. jsRule: "window.customFncs.formatTooltip()"
    43. },
    44. series: [{
    45. values: [1, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4]
    46. },
    47. {
    48. values: [6, 7, 8, 7, 6, 7, 8, 9, 8, 7, 8, 7, 8, 9, 8]
    49. }
    50. ]
    51. };
    52.  
    53. // simple associate array has
    54. var tooltipHistoryHash = [];
    55.  
    56. /*
    57. * Function under our ZC wrapper. Will
    58. * be fired when the node is hovered over
    59. *
    60. * @param {object} p ZingChart callback argument.
    61. * is associated to various graph properties
    62. */
    63. window.customFncs.formatTooltip = function(p) {
    64. console.log(p);
    65. var plotIndex = p.plotindex;
    66. var nodeIndex = p.nodeindex;
    67. var backgroundColor1 = "";
    68.  
    69. if (plotIndex === 1) {
    70. backgroundColor1 = "red";
    71. tooltipText = "Red Line";
    72. } else if (plotIndex === 0) {
    73. backgroundColor1 = "blue";
    74. tooltipText = "Blue Line";
    75. }
    76.  
    77. // Return and object with multiple properties
    78. return {
    79. text: tooltipText,
    80. backgroundColor: backgroundColor1
    81. }
    82. }
    83.  
    84. zingchart.render({
    85. id: 'myChart',
    86. data: myConfig,
    87. height: 400,
    88. width: 600
    89. });
    90. </script>
    91. </body>
    92.  
    93. </html>
    1. <!DOCTYPE html>
    2. <html>
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingSoft Demo</title>
    7.  
    8. <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    9. </head>
    10.  
    11. <body>
    12. <div id="myChart"><a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a></div>
    13. </body>
    14.  
    15. </html>
    1. html,
    2. body {
    3. height: 100%;
    4. width: 100%;
    5. margin: 0;
    6. padding: 0;
    7. }
    8.  
    9. #myChart {
    10. height: 100%;
    11. width: 100%;
    12. min-height: 150px;
    13. }
    14.  
    15. .zc-ref {
    16. display: none;
    17. }
    1. // Global wrapper
    2. window.customFncs = {};
    3.  
    4. var myConfig = {
    5. type: "line",
    6. title: {
    7. text: 'jsRule Demo'
    8. },
    9. tooltip: {
    10. jsRule: "window.customFncs.formatTooltip()"
    11. },
    12. series: [{
    13. values: [1, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4]
    14. },
    15. {
    16. values: [6, 7, 8, 7, 6, 7, 8, 9, 8, 7, 8, 7, 8, 9, 8]
    17. }
    18. ]
    19. };
    20.  
    21. // simple associate array has
    22. var tooltipHistoryHash = [];
    23.  
    24. /*
    25. * Function under our ZC wrapper. Will
    26. * be fired when the node is hovered over
    27. *
    28. * @param {object} p ZingChart callback argument.
    29. * is associated to various graph properties
    30. */
    31. window.customFncs.formatTooltip = function(p) {
    32. console.log(p);
    33. var plotIndex = p.plotindex;
    34. var nodeIndex = p.nodeindex;
    35. var backgroundColor1 = "";
    36.  
    37. if (plotIndex === 1) {
    38. backgroundColor1 = "red";
    39. tooltipText = "Red Line";
    40. } else if (plotIndex === 0) {
    41. backgroundColor1 = "blue";
    42. tooltipText = "Blue Line";
    43. }
    44.  
    45. // Return and object with multiple properties
    46. return {
    47. text: tooltipText,
    48. backgroundColor: backgroundColor1
    49. }
    50. }
    51.  
    52. zingchart.render({
    53. id: 'myChart',
    54. data: myConfig,
    55. height: 400,
    56. width: 600
    57. });