Skip to content

Commit

Permalink
✨ allow clicking on chart to view sheets in the bar
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaraku committed Jan 3, 2025
1 parent 22c7730 commit 400e458
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions components/SheetDataView.vue/SheetDataChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,32 @@ import { computed, inject, Ref } from '@nuxtjs/composition-api';
import VChart from 'vue-echarts/dist/csp';
import * as echarts from 'echarts';
import { useDataStore } from '~/stores/data';
import useGtag from '~/composables/useGtag';
import useGameInfo from '~/composables/useGameInfo';
import useGameData from '~/composables/useGameData';
import useSheetComboDialog from '~/composables/useSheetComboDialog';
import type { Sheet, Filters, FilterOptions } from '~/types';
import 'vue-echarts/dist/csp/style.css';
const sheets: Ref<Sheet[]> = inject('sheets')!;
const filters: Ref<Filters> = inject('filters')!;
const filterOptions: Ref<FilterOptions> = inject('filterOptions')!;
const gtag = useGtag();
const dataStore = useDataStore();
const { gameCode } = useGameInfo();
const { getTypeIndex, getDifficultyIndex } = useGameData();
const { viewSheetCombo } = useSheetComboDialog();
const data = computed(() => dataStore.currentData);
const sortedSheets = computed(() => sheets.value.toSorted(
(a, b) => 0
|| (b.levelValue ?? 0) - (a.levelValue ?? 0)
|| (b.internalLevelValue ?? 0) - (a.internalLevelValue ?? 0)
|| (b.internalLevel != null ? 1 : 0) - (a.internalLevel != null ? 1 : 0)
|| (getDifficultyIndex(b.difficulty)) - (getDifficultyIndex(a.difficulty))
|| (getTypeIndex(a.type)) - (getTypeIndex(b.type)),
));
function getSheetLevelValueInUse(sheet: Sheet) {
return (
Expand Down Expand Up @@ -92,6 +109,7 @@ const option = computed<echarts.EChartsOption>(() => ({
tooltip: {
trigger: 'axis',
order: 'seriesDesc',
extraCssText: 'z-index: 200 !important;',
},
xAxis: {
type: 'category',
Expand Down Expand Up @@ -123,6 +141,8 @@ const option = computed<echarts.EChartsOption>(() => ({
.filter((sheet) => getSheetDifficultyInUse(sheet) === difficulty)
.filter((sheet) => getSheetLevelValueInUse(sheet) === level.value)
.length,
_getSheets: () => sortedSheets.value
.filter((sheet) => getSheetLevelValueInUse(sheet) === level.value),
})),
} satisfies echarts.BarSeriesOption)),
],
Expand All @@ -136,6 +156,10 @@ const option = computed<echarts.EChartsOption>(() => ({
:init-options="initOptions"
:option="option"
autoresize
@click="
viewSheetCombo($event.data._getSheets());
gtag('event', 'SheetComboViewed', { gameCode, eventSource: 'SheetDataChart' });
"
/>
</div>
</template>
Expand Down

0 comments on commit 400e458

Please sign in to comment.