<template>
  <div  class="go-title-xuncha">
    <img class="img" :width="w" :height="h" src="@/assets/images/chart/xunchaguiji/personsicon01.png" />
    <div class="divbox">
      <span class="labelbox">{{ labelText }}</span>
      <span class="valbox">{{ dataset }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { useChartDataFetch } from '@/hooks';
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';

const props = defineProps({
  chartConfig: {
    type: Object as PropType<CreateComponentType>,
    required: true
  }
})

const { w, h } = toRefs(props.chartConfig.attr)
const {
  labelText,
  labelSize,
  labelColor,
  valSize,
  valColors,
  valFlod,
  dataset
} = toRefs(props.chartConfig.option)
 // 数据callback处理（预览时触发）
 useChartDataFetch(props.chartConfig, useChartEditStore, (resData: any[]) => {
  props.chartConfig.option.dataset = resData;
});
</script>

<style lang="scss" scoped>
@include go('title-xuncha') {
  position: relative;
  display: flex;
  align-items: center; 
  .img{
    position: absolute;
  }
  .divbox{
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 42%;
    .labelbox{
      color: v-bind('labelColor');
      font-size: v-bind('labelSize+"px"');
      line-height: 100%;
    }
    .valbox{
      font-size: v-bind('valSize+"px"');
      font-weight: v-bind('valFlod');
      background: linear-gradient(to bottom, v-bind('valColors[0]'), v-bind('valColors[1]')); 
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent; /* 兼容旧版浏览器 */
      background-clip: text; /* 标准语法 */
      color: transparent; /* 标准语法 */
      line-height: 100%;
    }
  }
}
</style>
