• 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. #myChart {
    13. height: 100%;
    14. width: 100%;
    15. }
    16. </style>
    17. </head>
    18.  
    19. <body>
    20. <div id='myChart'></div>
    21. <script>
    22. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
    23. var myConfig = {
    24. type: 'line',
    25. title: {
    26. text: 'Click On A Node'
    27. },
    28. plot: {
    29. tooltip: {
    30. visible: false
    31. },
    32. cursor: 'hand'
    33. },
    34. scaleX: {
    35. labels: ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun']
    36. },
    37. scaleY: {
    38. markers: []
    39. },
    40. series: [{
    41. values: [35, 42, 67, 89, 25, 34, 67]
    42. },
    43. {
    44. values: [15, 42, 67, 89, 25, 34, 67].sort()
    45. }
    46. ]
    47. };
    48.  
    49. zingchart.render({
    50. id: 'myChart',
    51. data: myConfig,
    52. height: '100%',
    53. width: '100%'
    54. });
    55.  
    56. /*
    57. * define marker class to construct
    58. * markers on the fly easier.
    59. */
    60. function Marker(_index, _text, _plotindex) {
    61. return {
    62. type: 'line',
    63. lineColor: (_plotindex == 0) ? '#4CAF50' : '#FFC107',
    64. lineWidth: 5,
    65. offsetY: (_plotindex == 0) ? -2 : 2,
    66. range: [_index],
    67. label: {
    68. text: _text,
    69. angle: 0,
    70. offsetY: (_plotindex == 0) ? 0 : 17,
    71. }
    72. }
    73. }
    74.  
    75. // global array for markers since you can only update the whole array
    76. var markersArray = [];
    77.  
    78. // hash table for markers
    79. var markerHashTable = {};
    80. markerHashTable['plotindex_0'] = {};
    81. markerHashTable['plotindex_1'] = {};
    82.  
    83. /*
    84. * Register a node_click event and then render a chart with the markers
    85. */
    86. zingchart.bind('myChart', 'node_click', function(e) {
    87. console.log(e)
    88.  
    89. // check hash table. Add marker
    90. if (!markerHashTable['plotindex_' + e.plotindex][e.value]) {
    91. var labelText = e.scaletext + ' plotindex: ' + e.plotindex + ' with a value of ' + e.value + ' was clicked';
    92.  
    93. // create a marker
    94. var newMarker = new Marker(e.value, labelText, e.plotindex);
    95.  
    96. markerHashTable['plotindex_' + e.plotindex][e.value] = true;
    97. markersArray.push(newMarker);
    98.  
    99. // render the marker
    100. myConfig.scaleY.markers = markersArray;
    101. zingchart.exec('myChart', 'setdata', {
    102. data: myConfig
    103. });
    104. }
    105.  
    106. });
    107. </script>
    108. </body>
    109.  
    110. </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'></div>
    13. </body>
    14.  
    15. </html>
    1. html,
    2. body,
    3. #myChart {
    4. height: 100%;
    5. width: 100%;
    6. }
    1. var myConfig = {
    2. type: 'line',
    3. title: {
    4. text: 'Click On A Node'
    5. },
    6. plot: {
    7. tooltip: {
    8. visible: false
    9. },
    10. cursor: 'hand'
    11. },
    12. scaleX: {
    13. labels: ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun']
    14. },
    15. scaleY: {
    16. markers: []
    17. },
    18. series: [{
    19. values: [35, 42, 67, 89, 25, 34, 67]
    20. },
    21. {
    22. values: [15, 42, 67, 89, 25, 34, 67].sort()
    23. }
    24. ]
    25. };
    26.  
    27. zingchart.render({
    28. id: 'myChart',
    29. data: myConfig,
    30. height: '100%',
    31. width: '100%'
    32. });
    33.  
    34. /*
    35. * define marker class to construct
    36. * markers on the fly easier.
    37. */
    38. function Marker(_index, _text, _plotindex) {
    39. return {
    40. type: 'line',
    41. lineColor: (_plotindex == 0) ? '#4CAF50' : '#FFC107',
    42. lineWidth: 5,
    43. offsetY: (_plotindex == 0) ? -2 : 2,
    44. range: [_index],
    45. label: {
    46. text: _text,
    47. angle: 0,
    48. offsetY: (_plotindex == 0) ? 0 : 17,
    49. }
    50. }
    51. }
    52.  
    53. // global array for markers since you can only update the whole array
    54. var markersArray = [];
    55.  
    56. // hash table for markers
    57. var markerHashTable = {};
    58. markerHashTable['plotindex_0'] = {};
    59. markerHashTable['plotindex_1'] = {};
    60.  
    61. /*
    62. * Register a node_click event and then render a chart with the markers
    63. */
    64. zingchart.bind('myChart', 'node_click', function(e) {
    65. console.log(e)
    66.  
    67. // check hash table. Add marker
    68. if (!markerHashTable['plotindex_' + e.plotindex][e.value]) {
    69. var labelText = e.scaletext + ' plotindex: ' + e.plotindex + ' with a value of ' + e.value + ' was clicked';
    70.  
    71. // create a marker
    72. var newMarker = new Marker(e.value, labelText, e.plotindex);
    73.  
    74. markerHashTable['plotindex_' + e.plotindex][e.value] = true;
    75. markersArray.push(newMarker);
    76.  
    77. // render the marker
    78. myConfig.scaleY.markers = markersArray;
    79. zingchart.exec('myChart', 'setdata', {
    80. data: myConfig
    81. });
    82. }
    83.  
    84. });