Skip to content

Commit

Permalink
fix: Manual color breakpoints sometimes not honored
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Apr 24, 2024
1 parent 4d1595a commit 9e07d4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/components/viz-configurator/FillColors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<script lang="ts">
import { defineComponent } from 'vue'
import type { PropType } from 'vue'
import { debounce } from 'debounce'
import globalStore from '@/store'
import { VizLayerConfiguration, DataTable, DataType } from '@/Globals'
Expand Down Expand Up @@ -166,6 +167,7 @@ export default defineComponent({
diffRelative: false,
diffUISelection: '',
diffChoices: [] as any[],
emitColorSpecification: {} as any,
flip: false,
isCurrentlyDiffMode: false,
join: '',
Expand All @@ -177,6 +179,8 @@ export default defineComponent({
}
},
mounted() {
this.emitColorSpecification = debounce(this.emitColorSpecificationDebounced, 150)
this.selectedSingleColor = this.simpleColors[0]
this.selectedColor = this.colorChoices[0]
this.datasetLabels = Object.keys(this.vizConfiguration.datasets)
Expand Down Expand Up @@ -312,7 +316,7 @@ export default defineComponent({
this.isCurrentlyDiffMode = !!this.diffUISelection
},
emitColorSpecification() {
emitColorSpecificationDebounced() {
// no fill
if (!this.dataColumn) return
Expand Down Expand Up @@ -360,7 +364,7 @@ export default defineComponent({
fill.colorRamp.breakpoints = this.vizConfiguration.display?.fill?.colorRamp?.breakpoints
}
setTimeout(() => this.$emit('update', { fill }), 50)
this.$emit('update', { fill })
},
clickedSingleColor(swatch: string) {
Expand All @@ -374,7 +378,7 @@ export default defineComponent({
// the viewer is on main thread so lets make
// sure user gets some visual feedback
setTimeout(() => this.$emit('update', { fill }), 25)
this.$emit('update', { fill })
},
columnsInDataset(datasetId: string): string[] {
Expand Down
10 changes: 7 additions & 3 deletions src/components/viz-configurator/LineColors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<script lang="ts">
import { defineComponent } from 'vue'
import type { PropType } from 'vue'
import { debounce } from 'debounce'
import globalStore from '@/store'
import { VizLayerConfiguration, DataTable, DataType } from '@/Globals'
Expand Down Expand Up @@ -166,6 +167,7 @@ export default defineComponent({
diffRelative: false,
diffUISelection: '',
diffChoices: [] as any[],
emitColorSpecification: {} as any,
flip: false,
isCurrentlyDiffMode: false,
join: '',
Expand All @@ -177,6 +179,8 @@ export default defineComponent({
}
},
mounted() {
this.emitColorSpecification = debounce(this.emitColorSpecificationDebounced, 150)
this.selectedSingleColor = this.simpleColors[0]
this.selectedColor = this.colorChoices[0]
this.datasetLabels = Object.keys(this.vizConfiguration.datasets)
Expand Down Expand Up @@ -312,7 +316,7 @@ export default defineComponent({
this.isCurrentlyDiffMode = !!this.diffUISelection
},
emitColorSpecification() {
emitColorSpecificationDebounced() {
// no data
if (!this.dataColumn) return
Expand Down Expand Up @@ -361,7 +365,7 @@ export default defineComponent({
this.vizConfiguration.display?.lineColor?.colorRamp?.breakpoints
}
setTimeout(() => this.$emit('update', { lineColor }), 50)
this.$emit('update', { lineColor })
},
clickedSingleColor(swatch: string) {
Expand All @@ -375,7 +379,7 @@ export default defineComponent({
// the viewer is on main thread so lets make
// sure user gets some visual feedback
setTimeout(() => this.$emit('update', { lineColor }), 50)
this.$emit('update', { lineColor })
},
columnsInDataset(datasetId: string): string[] {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/shape-file/ShapeFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,6 @@ const MyComponent = defineComponent({
const dataset2 = this.datasets[key2]
const relative = !!color.relative
// console.log('999 DIFF', relative, key1, key2, dataset1, dataset2)
if (dataset1 && dataset2) {
// generate the lookup columns we need
this.setupJoin({ datasetId: key1, dataTable: dataset1, dataJoinColumn: lookupColumn })
Expand Down Expand Up @@ -1084,6 +1082,7 @@ const MyComponent = defineComponent({
style: color.colorRamp?.style || 0,
reverse: color.colorRamp?.reverse || false,
steps: color.colorRamp?.steps || 9,
breakpoints: color.colorRamp?.breakpoints,
}
// Calculate colors for each feature
Expand Down Expand Up @@ -1282,6 +1281,7 @@ const MyComponent = defineComponent({
style: color.colorRamp?.style || 0,
reverse: color.colorRamp?.reverse || false,
steps: color.colorRamp?.steps || 9,
breakpoints: color.colorRamp?.breakpoints || undefined,
}
// Calculate colors for each feature
Expand Down

0 comments on commit 9e07d4f

Please sign in to comment.