update style with config

This commit is contained in:
Fine 2022-11-07 21:16:22 +08:00
parent a56c6c188d
commit 7c6a0bd380
4 changed files with 9 additions and 11 deletions

View File

@ -17,6 +17,10 @@
import { LegendOptions } from "@/types/dashboard"; import { LegendOptions } from "@/types/dashboard";
export default function useLegendProcess(legend?: LegendOptions) { export default function useLegendProcess(legend?: LegendOptions) {
let isRight = false;
if (legend && legend.toTheRight) {
isRight = true;
}
function showEchartsLegend(keys: string[]) { function showEchartsLegend(keys: string[]) {
if (legend && !legend.show === undefined) { if (legend && !legend.show === undefined) {
return legend.show; return legend.show;
@ -29,11 +33,6 @@ export default function useLegendProcess(legend?: LegendOptions) {
} }
return true; return true;
} }
function isRight() {
if (legend && legend.toTheRight) {
return true;
}
return false;
}
return { showEchartsLegend, isRight }; return { showEchartsLegend, isRight };
} }

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="graph"> <div class="graph" :class="isRight ? 'flex-h' : 'flex-v'">
<Graph :option="option" @select="clickEvent" :filters="config.filters" /> <Graph :option="option" @select="clickEvent" :filters="config.filters" />
<Legend :config="config.legend" :data="data" /> <Legend :config="config.legend" :data="data" />
</div> </div>
@ -49,7 +49,7 @@ const props = defineProps({
default: () => ({}), default: () => ({}),
}, },
}); });
const { showEchartsLegend } = useLegendProcess(props.config.legend); const { showEchartsLegend, isRight } = useLegendProcess(props.config.legend);
const option = computed(() => getOption()); const option = computed(() => getOption());
function getOption() { function getOption() {

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="graph flex-v" :class="toTheRight ? 'flex-h' : 'flex-v'"> <div class="graph flex-v" :class="isRight ? 'flex-h' : 'flex-v'">
<Graph <Graph
:option="option" :option="option"
@select="clickEvent" @select="clickEvent"
@ -65,7 +65,6 @@ const props = defineProps({
}, },
}); });
const { showEchartsLegend, isRight } = useLegendProcess(props.config.legend); const { showEchartsLegend, isRight } = useLegendProcess(props.config.legend);
const toTheRight = computed(() => isRight());
const option = computed(() => getOption()); const option = computed(() => getOption());
function getOption() { function getOption() {
const keys = Object.keys(props.data || {}).filter( const keys = Object.keys(props.data || {}).filter(

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div>legend</div> <div :style="`width: ${config.width || '100%'}`">legend</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from "vue"; import type { PropType } from "vue";