<template>
  <Filters
    @reset-form="data = []"
    @run-search="() => filterData(filters)"
    :report-button="true"
    class="mb-4"
  >
    <Type3 @update:filters="(value) => (filters = value)" />
  </Filters>

  <div>
    <DxDataGrid
      ref="dataGridRef"
      :allow-column-reordering="true"
      class="max-h-[calc(100vh-140px)] mb-10"
      :data-source="data"
      :show-column-lines="true"
      :show-row-lines="false"
      :show-borders="true"
      :row-alternation-enabled="true"
      :hover-state-enabled="true"
      @selection-changed="onDataSelectionChanged"
      :column-width="100"
      @exporting="onExporting"
      :allow-column-resizing="true"
      column-resizing-mode="widget"
      :word-wrap-enabled="true"
    >
      <DxSelection mode="single" />
      <DxPaging :enabled="false" />
      <DxScrolling column-rendering-mode="virtual" mode="virtual" />
      <DxLoadPanel
        shading-color="rgba(0,0,0,0.4)"
        :position="position"
        :show-indicator="showIndicator"
        :show-pane="showPane"
        :shading="shading"
        v-model:visible="loadingData"
        :enabled="true"
      />
      <DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
      <DxExport
        :enabled="true"
        :formats="['pdf', 'xlsx', 'document']"
        :allow-export-selected-data="false"
      />
      <DxColumnFixing :enabled="true" />

      <DxColumn
        :width="100"
        alignment="center"
        :calculateCellValue="(item: any) => data.findIndex((i) => i == item) + 1"
        caption="NO"
        css-class="custom-table-column"
        data-field="no"
        data-type="number"
        cell-template="formatNumber"
      />
      <DxColumn
        :width="170"
        alignment="center"
        data-field="media"
        caption="Nama Media"
        css-class="custom-table-column"
        cell-template="formatText"
      />
      <DxColumn alignment="center" caption="Tanggal" css-class="custom-table-column">
        <DxColumn
          :width="100"
          v-for="i in 31"
          alignment="center"
          :data-field="`tgl${i}`"
          data-type="number"
          :caption="i"
          css-class="custom-table-column"
          cell-template="formatNumber"
        />
      </DxColumn>

      <DxSummary>
        <DxTotalItem
          summary-type="sum"
          display-format="Call PLN 123"
          show-in-column="no"
          css-class="text-white !text-left"
        />
        <DxTotalItem
          v-for="i in 31"
          summary-type="sum"
          display-format="{0}"
          :column="`tgl${i}`"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="total"
          summary-type="sum"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
      </DxSummary>

      <template #formatNumber="{ data }">
        <p class="!text-right cursor-pointer">
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatText="{ data }">
        <p class="text-left cursor-pointer">
          {{ data.text }}
        </p>
      </template>
    </DxDataGrid>
  </div>

  <DetailDialog
    :open="dialogDetail"
    title="Rekapitulasi Keluhan Berdasarkan Media"
    @on-close="closedialogDetail"
    :full-width="true"
  >
    <div class="w-full mb-4 lg:w-[70%] lg:float-left">
      <div class="p-4 bg-white rounded-xl lg:mr-4">
        <DxDataGrid
          :allow-column-reordering="true"
          class="max-h-[calc(100vh-140px)]"
          :data-source="dataSub"
          :show-column-lines="true"
          :show-row-lines="false"
          :show-borders="true"
          :row-alternation-enabled="true"
          :hover-state-enabled="true"
          @selection-changed="onDataSubSelectionChanged"
          :column-width="100"
          @exporting="onExporting"
          :allow-column-resizing="true"
          column-resizing-mode="widget"
        >
          <DxSelection mode="single" />
          <DxPaging :page-size="20" :enabled="true" />
          <DxPager
            :visible="true"
            :allowed-page-sizes="[20, 50, 100]"
            display-mode="full"
            :show-page-size-selector="true"
            :show-info="true"
            :show-navigation-buttons="true"
          />
          <DxLoadPanel
            shading-color="rgba(0,0,0,0.4)"
            :position="position"
            :show-indicator="showIndicator"
            :show-pane="showPane"
            :shading="shading"
            v-model:visible="loadingSubData"
            :enabled="true"
          />
          <DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
          <DxExport
            :enabled="true"
            :formats="['pdf', 'xlsx', 'document']"
            :allow-export-selected-data="false"
          />

          <DxColumn
            css-class="custom-table-column"
            :width="50"
            alignment="center"
            :calculateCellValue="(item: any) => dataSub.findIndex((i) => i == item) + 1"
            data-type="number"
            caption="No"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="no_laporan"
            caption="No Laporan"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="waktu_lapor"
            caption="Tgl Lapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Dalam Proses Bidang"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Selesai Bidang Unit"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="durasi_response_time"
            caption="Durasi Response Time"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="durasi_recovery_time"
            caption="Durasi Recovery Time"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Status"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="idpel_nometer"
            caption="IDPEL/NO METER"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="nama_pelapor"
            caption="Nama Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field="alamat_pelapor"
            caption="Alamat Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="no_telp_pelapor"
            caption="No Tlp Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field="keterangan_pelapor"
            caption="Keterangan Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Rayon"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Uraian"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Respon Pelanggan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />

          <template #formatText="{ data }">
            <p class="text-left cursor-pointer">
              {{ data.text }}
            </p>
          </template>

          <template #formatNumber="{ data }">
            <p class="text-right cursor-pointer">
              {{ data.text }}
            </p>
          </template>

          <template #formatTime="{ data }">
            <p>
              {{ parseInt(data.text) ? formatWaktu(data.text) : '-' }}
            </p>
          </template>
        </DxDataGrid>
      </div>
    </div>

    <div class="w-full mb-4 lg:w-[30%] lg:float-right">
      <div class="p-4 space-y-2 bg-white rounded-xl">
        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">No Laporan:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.no_laporan" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tgl Lapor:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.waktu_lapor" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Dalam Proses Bidang:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.dalam_proses_bidang"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Selesai Bidang Unit:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.selesai_bidang_unit"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Response Time:</h3>
          <InputText
            :readonly="true"
            :value="
              parseInt(dataSubSelected?.durasi_response_time)
                ? formatWaktu(dataSubSelected?.durasi_response_time)
                : '-'
            "
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Recovery Time:</h3>
          <InputText
            :readonly="true"
            :value="
              parseInt(dataSubSelected?.durasi_recovery_time)
                ? formatWaktu(dataSubSelected?.durasi_recovery_time)
                : '-'
            "
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Status:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.status_akhir" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">IDPEL/NO METER:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.idpel_nometer" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Nama Pelapor:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.nama_pelapor" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Alamat Pelapor:</h3>
          <InputText
            :readonly="true"
            type="textarea"
            :value="dataSubSelected?.alamat_pelapor"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">NO Telp Pelapor:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.no_telp_pelapor"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Keterangan Pelapor:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.keterangan_pelapor"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Rayon:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.rayon" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Uraian:</h3>
          <InputText
            :readonly="true"
            type="textarea"
            :value="dataSubSelected?.uraian"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Response Pelanggan:</h3>
          <InputText
            :readonly="true"
            type="textarea"
            :value="dataSubSelected?.response_pelanggan"
            class-name="flex-1"
          />
        </div>
      </div>
    </div>
  </DetailDialog>
</template>

<script setup lang="ts">
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
import InputText from '@/components/InputText.vue'
import Filters from '@/components/Form/Filters.vue'
import Type3 from '@/components/Form/FiltersType/Type3.vue'
import { ref, onMounted, watch } from 'vue'
import { DxDataGrid } from 'devextreme-vue'
import {
  DxColumn,
  DxColumnFixing,
  DxExport,
  DxLoadPanel,
  DxPaging,
  DxPager,
  DxSummary,
  DxTotalItem,
  DxScrolling,
  DxSearchPanel,
  DxSelection
} from 'devextreme-vue/data-grid'
import { jsPDF } from 'jspdf'
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'

const client = apolloClient()
provideApolloClient(client)
const position = { of: '#data' }
const showIndicator = ref(true)
const shading = ref(true)
const showPane = ref(true)
const data = ref<any[]>([])
const dataSub = ref<any[]>([])
const dataSelected = ref<any>()
const dataSubSelected = ref<any>()
const dialogDetail = ref(false)
const closedialogDetail = () => (dialogDetail.value = false)
const loadingData = ref(false)
const loadingSubData = ref(false)

const filterData = async (params: any) => {
  const dateValue = params.periode.split(' s/d ')
  const { ulp, uid, up3 } = params

  const query = {
    dateFrom: dateValue[0]
      ? dateValue[0].split('-').reverse().join('-')
      : new Date().toISOString().slice(0, 10),
    dateTo: dateValue[1]
      ? dateValue[1].split('-').reverse().join('-')
      : new Date().toISOString().slice(0, 10),
    idUlp: ulp ? ulp.id : 0,
    idUid: uid ? uid.id : 0,
    idUp3: up3 ? up3.id : 0,
    media: ''
  }

  loadingData.value = true
  await requestGraphQl(queries.keluhan.rekap.rekapKeluhanBerdasarkanMedia, query)
    .then((result) => {
      if (result.data.data != undefined) {
        data.value = result.data.data.rekapitulasiKeluhanBerdasarkanMedia
      } else {
        data.value = []
      }
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {
      loadingData.value = false
    })
}

const getDetail = async () => {
  const dateValue = filters.value.periode.split(' s/d ')
  const selected = dataSelected.value

  const query = {
    dateFrom: dateValue[0]
      ? dateValue[0].split('-').reverse().join('-')
      : new Date().toISOString().slice(0, 10),
    dateTo: dateValue[1]
      ? dateValue[1].split('-').reverse().join('-')
      : new Date().toISOString().slice(0, 10),
    idUlp: selected?.id_ulp ? selected?.id_ulp : 0,
    idUid: selected?.id_uid ? selected?.id_uid : 0,
    idUp3: selected?.id_up3 ? selected?.id_up3 : 0
  }

  loadingSubData.value = true
  await requestGraphQl(queries.keluhan.rekap.rekapKeluhanAllDetail, query)
    .then((result) => {
      if (result.data.data != undefined) {
        dataSub.value = result.data.data.detailKeluhanAll
      } else {
        dataSub.value = []
      }
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {
      loadingSubData.value = false
    })
}

const dataGridRef = ref<DxDataGrid | null>(null)
const clearSelection = () => {
  const dataGrid = dataGridRef.value!.instance!
  dataGrid.clearSelection()
}
const showDetail = () => {
  clearSelection()
  dataSubSelected.value = null
  dialogDetail.value = true
  getDetail()
}

const onExporting = (e: any) => {
  if (e.format === 'pdf') {
    const doc = new jsPDF()

    exportToPdf({
      jsPDFDocument: doc,
      component: e.component,
      indent: 5
    }).then(() => {
      doc.save(`.pdf`)
    })
  } else {
    const workbook = new Workbook()
    const worksheet = workbook.addWorksheet('Employees')

    exportToExcel({
      component: e.component,
      worksheet,
      autoFilterEnabled: true
    }).then(() => {
      workbook.xlsx.writeBuffer().then((buffer: any) => {
        saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
      })
    })

    e.cancel = true
  }
}

const onDataSelectionChanged = ({ selectedRowsData }: any) => {
  if (selectedRowsData[0] != undefined) {
    dataSelected.value = selectedRowsData[0]
    showDetail()
  }
}

const onDataSubSelectionChanged = ({ selectedRowsData }: any) => {
  const data = selectedRowsData[0]
  dataSubSelected.value = data
}

const filters = ref()

onMounted(() => {
  if (import.meta.env.DEV) {
    data.value = [
      {
        media: 'Facebook',
        tgl1: 11,
        tgl2: 16,
        tgl3: 11,
        tgl4: 10,
        tgl5: 20,
        tgl6: 13,
        tgl7: 13,
        tgl8: 10,
        tgl9: 12,
        tgl10: 15,
        tgl11: 18,
        tgl12: 16,
        tgl13: 18,
        tgl14: 12,
        tgl15: 15,
        tgl16: 21,
        tgl17: 11,
        tgl18: 12,
        tgl19: 12,
        tgl20: 20,
        tgl21: 5,
        tgl22: 17,
        tgl23: 17,
        tgl24: 18,
        tgl25: 19,
        tgl26: 16,
        tgl27: 14,
        tgl28: 15,
        tgl29: 15,
        tgl30: 17,
        tgl31: 12,
        total: 451
      },
      {
        media: 'EMS',
        tgl1: 0,
        tgl2: 0,
        tgl3: 0,
        tgl4: 0,
        tgl5: 0,
        tgl6: 0,
        tgl7: 0,
        tgl8: 0,
        tgl9: 1,
        tgl10: 0,
        tgl11: 0,
        tgl12: 0,
        tgl13: 0,
        tgl14: 0,
        tgl15: 2,
        tgl16: 0,
        tgl17: 0,
        tgl18: 0,
        tgl19: 0,
        tgl20: 0,
        tgl21: 0,
        tgl22: 0,
        tgl23: 0,
        tgl24: 0,
        tgl25: 0,
        tgl26: 0,
        tgl27: 0,
        tgl28: 0,
        tgl29: 0,
        tgl30: 0,
        tgl31: 0,
        total: 3
      },
      {
        media: 'Email',
        tgl1: 64,
        tgl2: 92,
        tgl3: 124,
        tgl4: 95,
        tgl5: 82,
        tgl6: 67,
        tgl7: 51,
        tgl8: 93,
        tgl9: 87,
        tgl10: 77,
        tgl11: 76,
        tgl12: 90,
        tgl13: 70,
        tgl14: 51,
        tgl15: 103,
        tgl16: 80,
        tgl17: 92,
        tgl18: 87,
        tgl19: 65,
        tgl20: 66,
        tgl21: 42,
        tgl22: 110,
        tgl23: 104,
        tgl24: 76,
        tgl25: 73,
        tgl26: 73,
        tgl27: 49,
        tgl28: 58,
        tgl29: 81,
        tgl30: 71,
        tgl31: 71,
        total: 2420
      },
      {
        media: 'Twitter',
        tgl1: 19,
        tgl2: 20,
        tgl3: 25,
        tgl4: 19,
        tgl5: 26,
        tgl6: 9,
        tgl7: 16,
        tgl8: 24,
        tgl9: 19,
        tgl10: 16,
        tgl11: 12,
        tgl12: 25,
        tgl13: 19,
        tgl14: 28,
        tgl15: 22,
        tgl16: 25,
        tgl17: 20,
        tgl18: 19,
        tgl19: 11,
        tgl20: 19,
        tgl21: 21,
        tgl22: 24,
        tgl23: 24,
        tgl24: 24,
        tgl25: 13,
        tgl26: 22,
        tgl27: 18,
        tgl28: 8,
        tgl29: 22,
        tgl30: 26,
        tgl31: 23,
        total: 618
      },
      {
        media: 'PLN Mobile',
        tgl1: 2036,
        tgl2: 5694,
        tgl3: 5083,
        tgl4: 5314,
        tgl5: 4646,
        tgl6: 2164,
        tgl7: 2025,
        tgl8: 4229,
        tgl9: 4057,
        tgl10: 4363,
        tgl11: 4702,
        tgl12: 4338,
        tgl13: 2103,
        tgl14: 1809,
        tgl15: 3788,
        tgl16: 4275,
        tgl17: 4546,
        tgl18: 4861,
        tgl19: 4388,
        tgl20: 2387,
        tgl21: 2066,
        tgl22: 4116,
        tgl23: 4476,
        tgl24: 4620,
        tgl25: 6063,
        tgl26: 5138,
        tgl27: 2571,
        tgl28: 1972,
        tgl29: 6393,
        tgl30: 6756,
        tgl31: 5973,
        total: 126952
      },
      {
        media: 'Instagram',
        tgl1: 35,
        tgl2: 45,
        tgl3: 40,
        tgl4: 54,
        tgl5: 43,
        tgl6: 26,
        tgl7: 23,
        tgl8: 43,
        tgl9: 37,
        tgl10: 39,
        tgl11: 27,
        tgl12: 48,
        tgl13: 31,
        tgl14: 27,
        tgl15: 39,
        tgl16: 42,
        tgl17: 29,
        tgl18: 38,
        tgl19: 27,
        tgl20: 31,
        tgl21: 33,
        tgl22: 22,
        tgl23: 44,
        tgl24: 40,
        tgl25: 38,
        tgl26: 42,
        tgl27: 20,
        tgl28: 31,
        tgl29: 47,
        tgl30: 34,
        tgl31: 46,
        total: 1121
      },
      {
        media: 'Call PLN 123',
        tgl1: 739,
        tgl2: 1585,
        tgl3: 1533,
        tgl4: 1471,
        tgl5: 1380,
        tgl6: 1037,
        tgl7: 694,
        tgl8: 1421,
        tgl9: 1311,
        tgl10: 1351,
        tgl11: 1211,
        tgl12: 1139,
        tgl13: 965,
        tgl14: 590,
        tgl15: 1408,
        tgl16: 1332,
        tgl17: 1200,
        tgl18: 1239,
        tgl19: 1207,
        tgl20: 997,
        tgl21: 756,
        tgl22: 1640,
        tgl23: 1528,
        tgl24: 1358,
        tgl25: 1279,
        tgl26: 1209,
        tgl27: 946,
        tgl28: 651,
        tgl29: 1427,
        tgl30: 1489,
        tgl31: 1829,
        total: 37922
      },
      {
        media: 'Datang ke Kantor',
        tgl1: 0,
        tgl2: 0,
        tgl3: 0,
        tgl4: 0,
        tgl5: 0,
        tgl6: 0,
        tgl7: 0,
        tgl8: 0,
        tgl9: 0,
        tgl10: 0,
        tgl11: 0,
        tgl12: 0,
        tgl13: 0,
        tgl14: 0,
        tgl15: 0,
        tgl16: 0,
        tgl17: 0,
        tgl18: 0,
        tgl19: 0,
        tgl20: 0,
        tgl21: 1,
        tgl22: 0,
        tgl23: 1,
        tgl24: 0,
        tgl25: 0,
        tgl26: 0,
        tgl27: 0,
        tgl28: 0,
        tgl29: 0,
        tgl30: 28,
        tgl31: 0,
        total: 30
      },
      {
        media: 'Live Chat Website',
        tgl1: 1,
        tgl2: 5,
        tgl3: 6,
        tgl4: 6,
        tgl5: 3,
        tgl6: 3,
        tgl7: 5,
        tgl8: 2,
        tgl9: 6,
        tgl10: 4,
        tgl11: 0,
        tgl12: 2,
        tgl13: 1,
        tgl14: 1,
        tgl15: 3,
        tgl16: 1,
        tgl17: 5,
        tgl18: 1,
        tgl19: 3,
        tgl20: 1,
        tgl21: 2,
        tgl22: 2,
        tgl23: 0,
        tgl24: 1,
        tgl25: 2,
        tgl26: 1,
        tgl27: 0,
        tgl28: 1,
        tgl29: 2,
        tgl30: 1,
        tgl31: 1,
        total: 72
      },
      {
        media: 'Live Chat PLN Mobile',
        tgl1: 46,
        tgl2: 61,
        tgl3: 66,
        tgl4: 50,
        tgl5: 83,
        tgl6: 69,
        tgl7: 50,
        tgl8: 89,
        tgl9: 86,
        tgl10: 70,
        tgl11: 89,
        tgl12: 71,
        tgl13: 52,
        tgl14: 68,
        tgl15: 112,
        tgl16: 108,
        tgl17: 79,
        tgl18: 95,
        tgl19: 68,
        tgl20: 54,
        tgl21: 64,
        tgl22: 94,
        tgl23: 90,
        tgl24: 77,
        tgl25: 69,
        tgl26: 75,
        tgl27: 57,
        tgl28: 67,
        tgl29: 77,
        tgl30: 100,
        tgl31: 102,
        total: 2338
      },
      {
        media: 'Ulasan Aplikasi PLN Mobile',
        tgl1: 0,
        tgl2: 2,
        tgl3: 2,
        tgl4: 4,
        tgl5: 2,
        tgl6: 1,
        tgl7: 1,
        tgl8: 1,
        tgl9: 1,
        tgl10: 2,
        tgl11: 0,
        tgl12: 1,
        tgl13: 1,
        tgl14: 2,
        tgl15: 1,
        tgl16: 0,
        tgl17: 0,
        tgl18: 1,
        tgl19: 1,
        tgl20: 2,
        tgl21: 1,
        tgl22: 1,
        tgl23: 1,
        tgl24: 1,
        tgl25: 1,
        tgl26: 2,
        tgl27: 0,
        tgl28: 3,
        tgl29: 2,
        tgl30: 2,
        tgl31: 1,
        total: 40
      }
    ]
  }
})
</script>
