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