• Edit
  • Download
    1. <!doctype html>
    2. <html class="zc-html">
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingSoft Demo</title>
    7. <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
    8. <style>
    9. .chart--container {
    10. height: 100%;
    11. width: 100%;
    12. min-height: 530px;
    13. }
    14.  
    15. .zc-ref {
    16. display: none;
    17. }
    18. </style>
    19. </head>
    20.  
    21. <body class="zc-body">
    22. <div id="myChart" class="chart--container">
    23. <a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
    24. </div>
    25.  
    26. <script>
    27. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; // INIT
    28. // -----------------------------
    29. zingchart.loadModules('scalableyaxis', function(e) {
    30. // CHART CONFIG
    31. // -----------------------------
    32. let chartConfig = {
    33. type: 'line',
    34. title: {
    35. text: 'Click on the Scale to start the drag',
    36. adjustLayout: true,
    37. flat: true,
    38. },
    39. subtitle: {
    40. text: 'Click Button To Reset The Scales',
    41. },
    42. plotarea: {
    43. margin: 'dynamic',
    44. },
    45. scalableYaxis: { // need this object
    46. scalable: true,
    47. chartid: 'myChart', // could get chartId in a more dynamic way if needed
    48. },
    49. scaleY: {
    50. maxItems: 10,
    51. lineColor: '#e53935', // make scale line color match (not necessary)
    52. },
    53. scaleY2: {
    54. maxItems: 6,
    55. lineColor: '#9c27b0', // make scale line color match (not necessary)
    56. guide: {
    57. visible: false, // you can change this to true to show the guide
    58. },
    59. placement: 'default',
    60. },
    61. scaleY3: {
    62. lineColor: '#4caf50', // make scale line color match (not necessary)
    63. // dont even have to set maxItems!
    64. },
    65. scaleY4: {
    66. placement: 'default',
    67. lineColor: '#00bcd4', // make scale line color match (not necessary)
    68. },
    69. scaleY5: {
    70. lineColor: '#ffeb3b',
    71. },
    72. scaleY6: {
    73. lineColor: '#3f51b5',
    74. },
    75. series: [{
    76. values: [35, 42, 67, 89, 25, 34, 67, 85],
    77. lineColor: '#e53935',
    78. marker: {
    79. backgroundColor: '#e53935',
    80. },
    81. scales: 'scale-x, scale-y',
    82. }, {
    83. values: [135, 242, 167, 289, 325, 434, 567, 785],
    84. lineColor: '#9c27b0',
    85. marker: {
    86. backgroundColor: '#9c27b0',
    87. },
    88. scales: 'scale-x, scale-y-2',
    89. },
    90. {
    91. values: [25135, 25542, 33167, 22289, 32335, 43224, 51167, 73385],
    92. lineColor: '#4caf50',
    93. marker: {
    94. backgroundColor: '#4caf50',
    95. },
    96. scales: 'scale-x, scale-y-3',
    97. },
    98. {
    99. values: [5135, 2542, 3167, 2289, 3335, 4224, 5167, 7385],
    100. lineColor: '#00bcd4',
    101. marker: {
    102. backgroundColor: '#00bcd4',
    103. },
    104. scales: 'scale-x, scale-y-4',
    105. },
    106. {
    107. values: [135, 542, 167, 289, 335, 224, 1167, 385],
    108. lineColor: '#ffeb3b',
    109. marker: {
    110. backgroundColor: '#ffeb3b',
    111. },
    112. scales: 'scale-x, scale-y-5',
    113. },
    114. {
    115. values: [44135, 22542, 11167, 21289, 22335, 41224, 41167, 63385],
    116. lineColor: '#3f51b5',
    117. marker: {
    118. backgroundColor: '#3f51b5',
    119. },
    120. scales: 'scale-x, scale-y-6',
    121. }
    122. ],
    123. labels: [{
    124. x: '15px',
    125. y: '5px',
    126. text: 'Reset',
    127. border: '1px solid black',
    128. padding: '7px',
    129. borderRadius: '4px',
    130. cursor: 'pointer',
    131. id: 'reset-scales',
    132. hoverState: {
    133. border: '2px solid black',
    134. }
    135. }]
    136. };
    137.  
    138. // EVENTS
    139. // -----------------------------
    140. zingchart.bind(null, 'label_click', function(e) {
    141. if (e.labelid === 'reset-scales') {
    142. /*
    143. * custom events for the plugin.
    144. * 1) getscaleminmax - allows you to get the current minMax value
    145. * for each scale AND the original. This allows you to save the
    146. * state of the scales.
    147. * - maxValue/minValue are the original scale values
    148. * - _maxValue/_minValue are the new scale values
    149. *
    150. * 2) resetscales - will reset the scales to the original value
    151. */
    152. console.log(zingchart.exec(e.loader.id, 'getscaleminmax'))
    153. zingchart.exec(e.loader.id, 'resetscales');
    154. }
    155. });
    156.  
    157. // RENDER CHARTS
    158. // -----------------------------
    159. zingchart.render({
    160. id: 'myChart',
    161. data: chartConfig,
    162. height: '100%',
    163. width: '100%',
    164. modules: 'scalableYaxis'
    165. });
    166. });
    167. </script>
    168. </body>
    169.  
    170. </html>
    1. <!doctype html>
    2. <html class="zc-html">
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingSoft Demo</title>
    7. <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    8. </head>
    9.  
    10. <body class="zc-body">
    11. <div id="myChart" class="chart--container">
    12. <a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
    13. </div>
    14.  
    15. </body>
    16.  
    17. </html>
    1. .chart--container {
    2. height: 100%;
    3. width: 100%;
    4. min-height: 530px;
    5. }
    6.  
    7. .zc-ref {
    8. display: none;
    9. }
    1. // INIT
    2. // -----------------------------
    3. zingchart.loadModules('scalableyaxis', function(e) {
    4. // CHART CONFIG
    5. // -----------------------------
    6. let chartConfig = {
    7. type: 'line',
    8. title: {
    9. text: 'Click on the Scale to start the drag',
    10. adjustLayout: true,
    11. flat: true,
    12. },
    13. subtitle: {
    14. text: 'Click Button To Reset The Scales',
    15. },
    16. plotarea: {
    17. margin: 'dynamic',
    18. },
    19. scalableYaxis: { // need this object
    20. scalable: true,
    21. chartid: 'myChart', // could get chartId in a more dynamic way if needed
    22. },
    23. scaleY: {
    24. maxItems: 10,
    25. lineColor: '#e53935', // make scale line color match (not necessary)
    26. },
    27. scaleY2: {
    28. maxItems: 6,
    29. lineColor: '#9c27b0', // make scale line color match (not necessary)
    30. guide: {
    31. visible: false, // you can change this to true to show the guide
    32. },
    33. placement: 'default',
    34. },
    35. scaleY3: {
    36. lineColor: '#4caf50', // make scale line color match (not necessary)
    37. // dont even have to set maxItems!
    38. },
    39. scaleY4: {
    40. placement: 'default',
    41. lineColor: '#00bcd4', // make scale line color match (not necessary)
    42. },
    43. scaleY5: {
    44. lineColor: '#ffeb3b',
    45. },
    46. scaleY6: {
    47. lineColor: '#3f51b5',
    48. },
    49. series: [{
    50. values: [35, 42, 67, 89, 25, 34, 67, 85],
    51. lineColor: '#e53935',
    52. marker: {
    53. backgroundColor: '#e53935',
    54. },
    55. scales: 'scale-x, scale-y',
    56. }, {
    57. values: [135, 242, 167, 289, 325, 434, 567, 785],
    58. lineColor: '#9c27b0',
    59. marker: {
    60. backgroundColor: '#9c27b0',
    61. },
    62. scales: 'scale-x, scale-y-2',
    63. },
    64. {
    65. values: [25135, 25542, 33167, 22289, 32335, 43224, 51167, 73385],
    66. lineColor: '#4caf50',
    67. marker: {
    68. backgroundColor: '#4caf50',
    69. },
    70. scales: 'scale-x, scale-y-3',
    71. },
    72. {
    73. values: [5135, 2542, 3167, 2289, 3335, 4224, 5167, 7385],
    74. lineColor: '#00bcd4',
    75. marker: {
    76. backgroundColor: '#00bcd4',
    77. },
    78. scales: 'scale-x, scale-y-4',
    79. },
    80. {
    81. values: [135, 542, 167, 289, 335, 224, 1167, 385],
    82. lineColor: '#ffeb3b',
    83. marker: {
    84. backgroundColor: '#ffeb3b',
    85. },
    86. scales: 'scale-x, scale-y-5',
    87. },
    88. {
    89. values: [44135, 22542, 11167, 21289, 22335, 41224, 41167, 63385],
    90. lineColor: '#3f51b5',
    91. marker: {
    92. backgroundColor: '#3f51b5',
    93. },
    94. scales: 'scale-x, scale-y-6',
    95. }
    96. ],
    97. labels: [{
    98. x: '15px',
    99. y: '5px',
    100. text: 'Reset',
    101. border: '1px solid black',
    102. padding: '7px',
    103. borderRadius: '4px',
    104. cursor: 'pointer',
    105. id: 'reset-scales',
    106. hoverState: {
    107. border: '2px solid black',
    108. }
    109. }]
    110. };
    111.  
    112. // EVENTS
    113. // -----------------------------
    114. zingchart.bind(null, 'label_click', function(e) {
    115. if (e.labelid === 'reset-scales') {
    116. /*
    117. * custom events for the plugin.
    118. * 1) getscaleminmax - allows you to get the current minMax value
    119. * for each scale AND the original. This allows you to save the
    120. * state of the scales.
    121. * - maxValue/minValue are the original scale values
    122. * - _maxValue/_minValue are the new scale values
    123. *
    124. * 2) resetscales - will reset the scales to the original value
    125. */
    126. console.log(zingchart.exec(e.loader.id, 'getscaleminmax'))
    127. zingchart.exec(e.loader.id, 'resetscales');
    128. }
    129. });
    130.  
    131. // RENDER CHARTS
    132. // -----------------------------
    133. zingchart.render({
    134. id: 'myChart',
    135. data: chartConfig,
    136. height: '100%',
    137. width: '100%',
    138. modules: 'scalableYaxis'
    139. });
    140. });