rich:effect的用法

1

 

<!-- attaching by event  鼠标移走后,所在的panel变半透明-->
< rich:panel >
     < rich:effect   event = "onmouseout"   type = "Opacity"   params = "duration:0.8,from:1.0,to:0.3"   />
    .... panel content ....
</ rich:panel >
...

<!--  invoking from javascript 点Hide按钮,div隐藏;点Show按钮,div显示-->
< div   id = "contentDiv" >
  ..... div content ......
</ div >

< input   type = "button"   onclick = "hideDiv({duration:0.7})"   value = "Hide"   />
< input   type = "button"   onclick = "showDiv()"   value = "Show"   />

< rich:effect    name = "hideDiv"    for = "contentDiv"   type = "Fade"   />
< rich:effect    name = "showDiv"    for = "contentDiv"   type = "Appear"   />

<!-- attaching to window on load and applying on particular page element  页面刚加载时, contentDiv按params表达式显示 -->
< rich:effect   for = "window"   event = "onload"  
     type = "Appear"   params = "targetId:'contentDiv',duration:0.8,from:0.3,to:1.0"   />

 

我的示例:

 div在一开始不显示,当点击show时div显示,当点击Hide时div隐藏。

<rich:effect for="window" event="onload" 
    type="Fade" params="targetId:'contentDiv',duration:0.0,from:0.0,to:0.0" />


    <h:outputLabel onclick="showDiv()" value="show"  />
    | #{' '}
    <h:outputLabel onclick="hideDiv({duration:0.7})" value="hide"  />

<rich:effect  name="hideDiv"  for="contentDiv" type="BlindUp" />
<rich:effect  name="showDiv"  for="contentDiv" type="BlindDown" />
<div id="contentDiv">

。。。

 

</div>

<template> <div class="container"> <div class="charts-box"> <div class="pie-dec"> <el-tooltip effect="dark" :content="chartTotal" placement="bottom"> <div class="number"> {{ chartTotal }} <span class="unit">{{ mt('台') }}</span> </div> </el-tooltip> <el-tooltip effect="dark" :content="mt('盘活中资产')" placement="bottom"> <div class="title"> {{ mt('盘活中资产') }} </div> </el-tooltip> </div> <div id="totalchartBox" class="charts"></div> </div> <div class="capacity-label"> <div v-for="(item, index) in aggregatedData" :key="index" class="capacity-label-list"> <div class="type"> <div class="capacity-label-list-dot" :style="{ background: colorList[index] }"></div> {{ item.type }} </div> </div> </div> </div> </template> <script lang="ts" setup> import { computed, defineProps, onMounted, onUnmounted, ref, watch } from 'vue'; import { getI18n } from '@/util/i18n'; import * as echarts from 'echarts'; const { mt } = getI18n(); const chartOptions = ref({}); const myChart = ref(null); const props = defineProps({ activeName: { type: String, default: () => '', }, dataList: { type: Array, default: () => [], }, }); // 新增:按 type 聚合数据 const aggregatedData = computed(() => { const map = new Map<string, number>(); props.dataList.forEach(item => { const key = item.type; const value = item.count || 0; map.set(key, (map.get(key) || 0) + value); }); return Array.from(map.entries()).map(([type, count]) => ({ type, count })); }); // 总数量 const chartTotal = computed(() => { return aggregatedData.value.reduce((sum, item) => sum + item.count, 0); }); const seriesData = computed(() => { return aggregatedData.value.map(item => ({ value: item.count, name: item.type, })); }); const colorList = ['#2070F3', '#62B42E', '#715AFB', '#2CB8C9', '#F69E39', '#F3689A']; const initData = (data: Array) => { const chartDom = document.getElementById('totalchartBox'); if (myChart.value === null) { myChart.value = echarts.init(chartDom); } chartOptions.value = { tooltip: { trigger: 'item', }, color: colorList, series: [ { name: '', type: 'pie', radius: ['65%', '80%'], center: ['50%', '50%'], avoidLabelOverlap: false, itemStyle: { borderRadius: 0, borderColor: '#fff', borderWidth: 2, }, label: { show: true, position: 'outside', formatter: '{d}%', rich: { name: { fontSize: 12, fontWeight: 'bold', color: '#252b3a', lineHeight: 20, }, quantity: { fontSize: 11, color: '#666', lineHeight: 18, }, percent: { fontSize: 11, color: '#999', lineHeight: 18, }, }, lineHeight: 20, }, emphasis: { label: { show: true, fontWeight: 'bold', }, }, labelLine: { show: true, length: 10, length2: 15, smooth: false, lineStyle: { width: 1, color: '#ccc', }, }, data: data, }, ], }; myChart.value.setOption(chartOptions.value, true); window.addEventListener('resize', () => { myChart.value.resize(); }); }; watch( () => props.dataList, () => { initData(seriesData.value); }, { deep: true } ); watch( () => props.activeName, () => { initData(seriesData.value); }, { deep: true } ); onMounted(() => { window.addEventListener('resize', myChart.value.resize()); }); onUnmounted(() => { window.removeEventListener('resize', myChart.value.dispose()); }); </script> <i18n lang="json"> { "zh": { "版本": "版本", "数量": "数量", "占比": "占比" }, "en": { "版本": "version", "数量": "Quantity", "占比": "Proportion" } } </i18n> <style lang="less" scoped> .dark { .capacity-label-title { color: #dfe1e6; } .capacity-label-list { color: #dfe1e6; } } .charts-box { display: flex; justify-content: center; align-items: center; .pie-dec { position: absolute; text-align: center; z-index: 10; .number { font-size: 32px; font-weight: 600; color: #191919; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; .unit { font-size: 16px; font-weight: 400; } } .title { font-size: 12px; color: #8a8e99; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100px; } } } .dark { .pie-dec { .number { color: #dfe1e6; } } } .charts { width: 400px; height: 190px; } .capacity-label { display: flex; justify-content: center; font-size: 14px; &-title { margin-bottom: 4px; display: flex; justify-content: space-around; color: #8a8e99; } &-list { display: flex; justify-content: space-around; align-items: center; line-height: 20px; &-dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; } } .type { width: auto; margin-right: 25px; display: flex; flex-wrap: nowrap; align-items: center; } } </style> 帮我看看代码
最新发布
11-25
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值