line-with-data-labels.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <title>Line with Data Labels</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #chart {
  11. max-width: 650px;
  12. margin: 35px auto;
  13. }
  14. </style>
  15. <script>
  16. window.Promise ||
  17. document.write(
  18. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  19. )
  20. window.Promise ||
  21. document.write(
  22. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  23. )
  24. window.Promise ||
  25. document.write(
  26. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  27. )
  28. </script>
  29. <script src="https://cdn.jsdelivr.net/npm/react@16.12/umd/react.production.min.js"></script>
  30. <script src="https://cdn.jsdelivr.net/npm/react-dom@16.12/umd/react-dom.production.min.js"></script>
  31. <script src="https://cdn.jsdelivr.net/npm/prop-types@15.7.2/prop-types.min.js"></script>
  32. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  33. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  34. <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.3.6/dist/react-apexcharts.iife.min.js"></script>
  35. </head>
  36. <body>
  37. <div id="app"></div>
  38. <div id="html">
  39. &lt;div id=&quot;chart&quot;&gt;
  40. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;line&quot; height={350} /&gt;
  41. &lt;/div&gt;
  42. </div>
  43. <script type="text/babel">
  44. class ApexChart extends React.Component {
  45. constructor(props) {
  46. super(props);
  47. this.state = {
  48. series: [
  49. {
  50. name: "High - 2013",
  51. data: [28, 29, 33, 36, 32, 32, 33]
  52. },
  53. {
  54. name: "Low - 2013",
  55. data: [12, 11, 14, 18, 17, 13, 13]
  56. }
  57. ],
  58. options: {
  59. chart: {
  60. height: 350,
  61. type: 'line',
  62. dropShadow: {
  63. enabled: true,
  64. color: '#000',
  65. top: 18,
  66. left: 7,
  67. blur: 10,
  68. opacity: 0.2
  69. },
  70. toolbar: {
  71. show: false
  72. }
  73. },
  74. colors: ['#77B6EA', '#545454'],
  75. dataLabels: {
  76. enabled: true,
  77. },
  78. stroke: {
  79. curve: 'smooth'
  80. },
  81. title: {
  82. text: 'Average High & Low Temperature',
  83. align: 'left'
  84. },
  85. grid: {
  86. borderColor: '#e7e7e7',
  87. row: {
  88. colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
  89. opacity: 0.5
  90. },
  91. },
  92. markers: {
  93. size: 1
  94. },
  95. xaxis: {
  96. categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
  97. title: {
  98. text: 'Month'
  99. }
  100. },
  101. yaxis: {
  102. title: {
  103. text: 'Temperature'
  104. },
  105. min: 5,
  106. max: 40
  107. },
  108. legend: {
  109. position: 'top',
  110. horizontalAlign: 'right',
  111. floating: true,
  112. offsetY: -25,
  113. offsetX: -5
  114. }
  115. },
  116. };
  117. }
  118. render() {
  119. return (
  120. <div>
  121. <div id="chart">
  122. <ReactApexChart options={this.state.options} series={this.state.series} type="line" height={350} />
  123. </div>
  124. <div id="html-dist"></div>
  125. </div>
  126. );
  127. }
  128. }
  129. const domContainer = document.querySelector('#app');
  130. ReactDOM.render(React.createElement(ApexChart), domContainer);
  131. </script>
  132. </body>
  133. </html>