{"version":3,"file":"bar-chart.mjs","sources":["../../../../../../packages/components/chart/src/bar-chart.vue"],"sourcesContent":["<template>\n  <Bar\n    :options=\"computedChartOptions\"\n    :data=\"chartData\"\n    :dataset-id-key=\"datasetIdKey\"\n    :plugins=\"plugins\"\n    :update-mode=\"updateMode\"\n    :width=\"width\"\n    :height=\"height\"\n    data-test-name=\"bar-chart\"\n    data-test-variant=\"\"\n    data-test-state=\"\"\n  />\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { Bar } from 'vue-chartjs'\nimport * as ChartJS from 'chart.js'\nimport { cloneDeep, merge } from 'lodash-unified'\nimport { getChartDefaultOptions } from './utils'\nimport type { PropType } from 'vue'\nimport type { ChartData, ChartOptions, Plugin } from 'chart.js'\n\nconst {\n  BarElement,\n  CategoryScale,\n  Chart,\n  Legend,\n  LinearScale,\n  Title,\n  Tooltip,\n} = ChartJS\nChart.register(Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale)\n\ndefineOptions({ name: 'BBarChart' })\n\nconst props = defineProps({\n  datasetIdKey: {\n    type: String,\n    default: 'label',\n  },\n  width: {\n    type: Number,\n    default: 480,\n  },\n  height: {\n    type: Number,\n    default: 240,\n  },\n  plugins: {\n    type: Array as PropType<Plugin<'bar'>[]>,\n    default: () => [],\n  },\n  chartData: {\n    type: Object as PropType<ChartData<'bar', number[], unknown>>,\n    default: () => ({ datasets: [] }),\n  },\n  chartOptions: {\n    type: Object as PropType<ChartOptions<'bar'>>,\n    default: () => ({ responsive: true, maintainAspectRatio: true }),\n  },\n  updateMode: {\n    type: String as PropType<\n      | 'default'\n      | 'reset'\n      | 'resize'\n      | 'none'\n      | 'hide'\n      | 'show'\n      | 'active'\n      | undefined\n    >,\n    default: undefined,\n  },\n})\n\nconst defaultOptions = cloneDeep(\n  getChartDefaultOptions('bar')\n) as ChartOptions<'bar'>\n\nconst isHorizontal = computed(() => props.chartOptions.indexAxis === 'y')\nconst isStacked = computed(\n  () =>\n    props.chartOptions.scales?.x?.stacked ??\n    props.chartOptions.scales?.y?.stacked ??\n    false\n)\nconst computedChartOptions = computed(() =>\n  merge(\n    merge(defaultOptions, {\n      elements: isStacked.value\n        ? {\n            bar: {\n              borderSkipped: 'middle',\n            },\n          }\n        : {},\n      scales: {\n        x: { grid: { display: isHorizontal.value } },\n        y: { grid: { display: !isHorizontal.value } },\n      },\n    }),\n    props.chartOptions\n  )\n)\n</script>\n"],"names":["DO_defineComponent"],"mappings":";;;;;;;AAmCc,MAAA,WAAA,GAAAA,eAAA,CAAA,EAAE,IAAA,EAAM,aAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAX5B,IAAA,MAAA;AAAA,MACJ,UAAA;AAAA,MACA,aAAA;AAAA,MACA,KAAA;AAAA,MACA,MAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA;AAAA,MACA,OAAA;AAAA,KACE,GAAA,OAAA,CAAA;AACJ,IAAA,KAAA,CAAM,SAAS,KAAO,EAAA,OAAA,EAAS,MAAQ,EAAA,UAAA,EAAY,eAAe,WAAW,CAAA,CAAA;AA4C7E,IAAA,MAAM,cAAiB,GAAA,SAAA;AAAA,MACrB,uBAAuB,KAAK,CAAA;AAAA,KAC9B,CAAA;AAEA,IAAA,MAAM,eAAe,QAAS,CAAA,MAAM,KAAM,CAAA,YAAA,CAAa,cAAc,GAAG,CAAA,CAAA;AACxE,IAAA,MAAM,SAAY,GAAA,QAAA;AAAA,MAChB,MACE,KAAM,CAAA,YAAA,CAAa,MAAQ,EAAA,CAAA,EAAG,WAC9B,KAAM,CAAA,YAAA,CAAa,MAAQ,EAAA,CAAA,EAAG,OAC9B,IAAA,KAAA;AAAA,KACJ,CAAA;AACA,IAAA,MAAM,oBAAuB,GAAA,QAAA;AAAA,MAAS,MACpC,KAAA;AAAA,QACE,MAAM,cAAgB,EAAA;AAAA,UACpB,QAAA,EAAU,UAAU,KAChB,GAAA;AAAA,YACE,GAAK,EAAA;AAAA,cACH,aA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