戒酒的李白

【01/02.js】创建并配置多个ApexCharts图表和Leaflet地图,响应主题颜色变化

This diff could not be displayed because it is too large.
  1 +(function(jQuery) {
  2 +
  3 + "use strict";
  4 + // for apexchart
  5 + function apexChartUpdate(chart, detail) {
  6 + let color = getComputedStyle(document.documentElement).getPropertyValue('--dark');
  7 + if (detail.dark) {
  8 + color = getComputedStyle(document.documentElement).getPropertyValue('--white');
  9 + }
  10 + chart.updateOptions({
  11 + chart: {
  12 + foreColor: color
  13 + }
  14 + })
  15 + }
  16 +
  17 + if (jQuery("#hospital-chart-02").length) var donut = new Morris.Donut({
  18 + element: "hospital-chart-02",
  19 + resize: !0,
  20 + colors: ["#4788ff", "#4fd69c", "#37d5f2", "#f75676"],
  21 + data: [
  22 + {
  23 + label: "New Patient",
  24 + value: 40
  25 + },
  26 + {
  27 + label: "Exit Patient",
  28 + value: 12
  29 + },
  30 + {
  31 + label: "ICU Patient",
  32 + value: 20
  33 + },
  34 + {
  35 + label: "Discharge Patient",
  36 + value: 33
  37 + }
  38 + ],
  39 + hideHover: "auto"
  40 + });
  41 +
  42 + if (jQuery("#hospital-chart-03").length) {
  43 + const options = {
  44 + series: [{
  45 + name: 'Operation',
  46 + data: [44, 25, 10, 60, 50, 25, 40, 20]
  47 + }, {
  48 + name: 'Visitors',
  49 + data: [25, 38, 70, 0, 30, 15, 30, 30]
  50 + }],
  51 + colors: ['#4788ff', '#4fd69c'],
  52 + chart: {
  53 + type: 'bar',
  54 + height: 340,
  55 + stacked: true,
  56 + zoom: {
  57 + enabled: true
  58 + }
  59 + },
  60 + responsive: [{
  61 + breakpoint: 580,
  62 + options: {
  63 + legend: {
  64 + position: 'bottom',
  65 + offsetX: -30,
  66 + offsetY: 0,
  67 + }
  68 + }
  69 + }],
  70 + plotOptions: {
  71 + bar: {
  72 + horizontal: false,
  73 + borderRadius: 4
  74 + },
  75 + },
  76 + xaxis: {
  77 + type: 'category',
  78 + categories: ['India', 'Canada', 'U.S.A', 'Africa', 'London ', 'Europe ','Dubai','Kuvet'],
  79 + },
  80 + yaxis: {
  81 + labels: {
  82 + offsetY: 0,
  83 + minWidth: 20,
  84 + maxWidth: 20,
  85 + }
  86 + },
  87 + legend: {
  88 + position: 'top',
  89 + offsetX: -35
  90 + },
  91 + fill: {
  92 + opacity: 1
  93 + },
  94 + dataLabels: {
  95 + enabled: false
  96 + }
  97 + };
  98 +
  99 + const chart = new ApexCharts(document.querySelector("#hospital-chart-03"), options);
  100 + chart.render();
  101 + const body = document.querySelector('body')
  102 + if (body.classList.contains('dark')) {
  103 + apexChartUpdate(chart, {
  104 + dark: true
  105 + })
  106 + }
  107 +
  108 + document.addEventListener('ChangeColorMode', function (e) {
  109 + apexChartUpdate(chart, e.detail)
  110 + })
  111 +
  112 + }
  113 +
  114 + if (jQuery("#dash-chart-04").length) {
  115 + const options = {
  116 + series: [{
  117 + name: 'Success',
  118 + data: [110, 85, 87, 40, 45, 20, 91, 45, 94, 88]
  119 + }, {
  120 + name: 'Failed',
  121 + data: [40, 55, 35, 30, 75, 80, 63, 45, 66, 115]
  122 + }],
  123 + chart: {
  124 + type: 'bar',
  125 + height: 280
  126 + },
  127 + colors: ['#4788ff', '#f75676'],
  128 + plotOptions: {
  129 + bar: {
  130 + horizontal: false,
  131 + borderRadius: 4
  132 + },
  133 + },
  134 + legend: {
  135 + position: 'bottom',
  136 + offsetX: 35
  137 + },
  138 + dataLabels: {
  139 + enabled: false
  140 + },
  141 + stroke: {
  142 + show: true,
  143 + width: 2,
  144 + colors: ['transparent']
  145 + },
  146 + xaxis: {
  147 + categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct'],
  148 + },
  149 + yaxis: {
  150 + title: {
  151 + text: '$ (thousands)'
  152 + },
  153 + labels: {
  154 + offsetY: 0,
  155 + minWidth: 20,
  156 + maxWidth: 20,
  157 + }
  158 + },
  159 + fill: {
  160 + opacity: 1
  161 + },
  162 + tooltip: {
  163 + y: {
  164 + formatter: function (val) {
  165 + return "$ " + val + " thousands"
  166 + }
  167 + }
  168 + }
  169 + };
  170 +
  171 + const chart = new ApexCharts(document.querySelector("#dash-chart-04"), options);
  172 + chart.render();
  173 + const body = document.querySelector('body')
  174 + if (body.classList.contains('dark')) {
  175 + apexChartUpdate(chart, {
  176 + dark: true
  177 + })
  178 + }
  179 +
  180 + document.addEventListener('ChangeColorMode', function (e) {
  181 + apexChartUpdate(chart, e.detail)
  182 + })
  183 +
  184 + }
  185 +
  186 + if (jQuery("#hospital-chart-05").length) {
  187 + var options = {
  188 + series: [22, 83, 10, 30],
  189 + colors: ['#f75676', '#4fd69c', '#37d5f2', '#4788ff'],
  190 + chart: {
  191 + height: 290,
  192 + type: 'pie',
  193 + },
  194 + legend: {
  195 + position: 'bottom',
  196 + offsetX: 0
  197 + },
  198 + labels: ['Cancelled', 'Completed', 'Pending', 'Upcoming'],
  199 +
  200 + };
  201 + var chart = new ApexCharts(document.querySelector("#hospital-chart-05"), options);
  202 + chart.render();
  203 + const body = document.querySelector('body')
  204 + if (body.classList.contains('dark')) {
  205 + apexChartUpdate(chart, {
  206 + dark: true
  207 + })
  208 + }
  209 +
  210 + document.addEventListener('ChangeColorMode', function (e) {
  211 + apexChartUpdate(chart, e.detail)
  212 + })
  213 + }
  214 +
  215 +})(jQuery);