-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] [DataSet] [Chart] Support grouped histograms (close #612)
- Loading branch information
Showing
9 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ export enum Type | |
BAR = ('BAR'), | ||
AREA = ('AREA'), | ||
PIE = ('PIE'), | ||
HISTOGRAM = ('HISTOGRAM'), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
core/datacap-web/src/components/visual/components/VisualHistogram.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<div> | ||
<div ref="content" | ||
:style="{width: width, height: height}"> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import {Configuration} from "@/components/visual/Configuration" | ||
import VChart from '@visactor/vchart' | ||
import {cloneDeep} from "lodash"; | ||
let instance: VChart | ||
export default { | ||
name: 'VisualHistogram', | ||
props: { | ||
configuration: { | ||
type: Configuration | ||
}, | ||
submitted: { | ||
type: Boolean, | ||
default: true | ||
}, | ||
width: { | ||
type: String, | ||
default: () => '100%' | ||
}, | ||
height: { | ||
type: String, | ||
default: () => '400px' | ||
} | ||
}, | ||
watch: { | ||
configuration: { | ||
handler: 'handlerReset', | ||
deep: true | ||
} | ||
}, | ||
created() | ||
{ | ||
this.handlerInitialize(false) | ||
}, | ||
methods: { | ||
handlerInitialize(reset: boolean) | ||
{ | ||
setTimeout(() => { | ||
try { | ||
const options = { | ||
type: 'histogram', | ||
data: [{values: this.configuration.columns}], | ||
xField: this.configuration.chartConfigure.xAxis, | ||
x2Field: this.configuration.chartConfigure?.x2Axis, | ||
yField: this.configuration.chartConfigure.yAxis | ||
} | ||
if (!reset) { | ||
instance = new VChart(options, {dom: this.$refs.content}) | ||
instance.renderAsync() | ||
} | ||
else { | ||
instance.updateSpec(options, true) | ||
} | ||
if (this.submitted) { | ||
const cloneOptions = cloneDeep(this.configuration) | ||
cloneOptions.headers = [] | ||
cloneOptions.columns = [] | ||
this.$emit('commitOptions', cloneOptions) | ||
} | ||
} | ||
catch (e) { | ||
console.warn(e) | ||
} | ||
}) | ||
}, | ||
handlerReset() | ||
{ | ||
this.handlerInitialize(true) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.../datacap-web/src/views/admin/dataset/components/adhoc/DatasetVisualConfigureHistogram.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<template> | ||
<div> | ||
<Form :model="formState" | ||
:label-width="60"> | ||
<FormItem prop="xAxis" | ||
:label="$t('dataset.visualConfigureCategoryLeftField')"> | ||
<Select v-model="formState.xAxis"> | ||
<Option v-for="item in columns" | ||
:key="item" | ||
:value="item"> | ||
{{ item }} | ||
</Option> | ||
</Select> | ||
</FormItem> | ||
<FormItem prop="x2Axis" | ||
:label="$t('dataset.visualConfigureCategoryRightField')"> | ||
<Select v-model="formState.x2Axis"> | ||
<Option v-for="item in columns" | ||
:key="item" | ||
:value="item"> | ||
{{ item }} | ||
</Option> | ||
</Select> | ||
</FormItem> | ||
<FormItem prop="yAxis" | ||
:label="$t('dataset.visualConfigureValueField')"> | ||
<Select v-model="formState.yAxis"> | ||
<Option v-for="item in columns" | ||
:key="item" | ||
:value="item"> | ||
{{ item }} | ||
</Option> | ||
</Select> | ||
</FormItem> | ||
</Form> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
export default { | ||
name: 'DatasetVisualConfigureHistogram', | ||
props: { | ||
columns: { | ||
type: Array, | ||
default: () => [] | ||
} | ||
}, | ||
watch: { | ||
formState: { | ||
handler: 'handlerCommit', | ||
deep: true | ||
} | ||
}, | ||
data() | ||
{ | ||
return { | ||
formState: { | ||
xAxis: null, | ||
x2Axis: null, | ||
yAxis: null | ||
} | ||
} | ||
}, | ||
methods: { | ||
handlerCommit() | ||
{ | ||
this.$emit('commit', this.formState) | ||
} | ||
} | ||
}; | ||
</script> |