|
35 | 35 | import { coreStore } from '@/stores/app' |
36 | 36 | import { useI18n } from 'vue-i18n' |
37 | 37 | import type { UserSelection } from '@/components/util/HighlightSelect.vue' |
38 | | - import { CellCategory } from '@/plugins/types/gridscore' |
| 38 | + import { CellCategory, TraitDataType } from '@/plugins/types/gridscore' |
39 | 39 |
|
40 | 40 | // Only register the chart types we're actually using to reduce the final bundle size |
41 | 41 | Plotly.register([ |
|
98 | 98 | }) |
99 | 99 |
|
100 | 100 | const sortedDates = [...allDates].sort((a, b) => a - b) |
| 101 | + const isCategorical = compProps.trait.dataType === TraitDataType.categorical |
101 | 102 |
|
102 | 103 | let selectedItems: string[] = [] |
103 | 104 | const datapoints: { [index: string]: (number | null)[] } = {} |
|
158 | 159 | const timeIndex = sortedDates.indexOf(time) |
159 | 160 |
|
160 | 161 | const existingValues = m.values.filter(v => v !== undefined && v !== null) |
161 | | - const avg = existingValues.length > 0 ? existingValues.reduce((acc, val) => acc + (+val), 0) / existingValues.length : 0 |
| 162 | + const avg = existingValues.length > 0 ? existingValues.reduce((acc: number, val) => acc + (+val), 0) / existingValues.length : 0 |
162 | 163 |
|
163 | 164 | // Update statistics |
164 | 165 | if (avg !== undefined) { |
|
248 | 249 | title: { text: compProps.trait.name, font: { color: store.storeIsDarkMode ? 'white' : 'black' } }, |
249 | 250 | tickfont: { color: store.storeIsDarkMode ? 'white' : 'black' }, |
250 | 251 | fixedrange: !interactive.value, |
| 252 | + tickmode: isCategorical ? 'array' : undefined, |
| 253 | + tickvals: isCategorical ? compProps.trait.restrictions?.categories?.map((c, i) => i) : undefined, |
| 254 | + ticktext: isCategorical ? compProps.trait.restrictions?.categories : undefined, |
251 | 255 | }, |
252 | 256 | shapes: [] as any[], |
253 | 257 | annotations: [] as any[], |
|
0 commit comments