|
@@ -1,224 +1,131 @@
|
|
|
<template>
|
|
|
<Card title="成交占比" :loading="loading">
|
|
|
- <div ref="chartRef2" :style="{ width, height }"></div>
|
|
|
+ <template #extra>
|
|
|
+ <div class="condition">
|
|
|
+ <div class="selct" style="display: inline-block;">
|
|
|
+ <span style="margin-right:15px">颗粒度</span>
|
|
|
+ <Select
|
|
|
+ v-model:value="value"
|
|
|
+ label-in-value
|
|
|
+ style="width: 100px;margin-right:30px"
|
|
|
+ placeholder="请选择颗粒度"
|
|
|
+ :options="options"
|
|
|
+ @change="handleChange"
|
|
|
+ ></Select>
|
|
|
+ </div>
|
|
|
+ <a-button type="primary" >导出</a-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div ref="chartRef" :style="{ height, width }"></div>
|
|
|
</Card>
|
|
|
</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { basicProps } from './props';
|
|
|
+ // import { dateUtil } from '/@/utils/dateUtil';
|
|
|
+ import { Card, Select } from 'ant-design-vue';
|
|
|
+</script>
|
|
|
<script lang="ts" setup>
|
|
|
-import { Ref, ref, watch } from 'vue';
|
|
|
-import { Card } from 'ant-design-vue';
|
|
|
-import { useECharts } from '/@/hooks/web/useECharts';
|
|
|
-const colorList = ['#9E87FF', '#73DDFF', '#fe9a8b', '#F56948', '#9E87FF'];
|
|
|
-const shadowColor = ['rgba(158,135,255, 0.3)','rgba(115,221,255, 0.3)','rgba(254,154,139, 0.3)']
|
|
|
-const props = defineProps({
|
|
|
+ import { ref, Ref, watch } from 'vue';
|
|
|
+ // import type { dataItemType } from './props';
|
|
|
+ import { useECharts } from '/@/hooks/web/useECharts';
|
|
|
+ const props = defineProps({
|
|
|
loading: Boolean,
|
|
|
- width: {
|
|
|
- type: String as PropType<string>,
|
|
|
- default: '100%',
|
|
|
- },
|
|
|
- height: {
|
|
|
- type: String as PropType<string>,
|
|
|
- default: '300px',
|
|
|
- },
|
|
|
- propsData:{
|
|
|
- type:Object,
|
|
|
- default:{
|
|
|
- xData:['北京', '上海', '广州', '深圳', '香港', '澳门', '台湾'],
|
|
|
- yData:['北京', '上海', '广州', '深圳', '香港', '澳门', '台湾'],
|
|
|
- }
|
|
|
+ ...basicProps,
|
|
|
+ });
|
|
|
+ const value = ref('a1');
|
|
|
+ const options = ref<SelectProps['options']>([
|
|
|
+ {
|
|
|
+ value: 'jack',
|
|
|
+ label: 'Jack (100)',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'lucy',
|
|
|
+ label: 'Lucy (101)',
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ const viewStaticsData = ref<number[]>([1,5,6,8,55,1,5,6,8,1]);
|
|
|
+ const shareStaticsData = ref<number[]>([2,55,10,2,6,1,5,6,8,1]);
|
|
|
+ const yixStringData = ref<string[]>(['11','22','33','44','ss','11','22','33','44','ss']);
|
|
|
+ const maxSize = ref(0);
|
|
|
+ const chartRef = ref<HTMLDivElement | null>(null);
|
|
|
+ const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
|
|
|
+ function handleChange(val){
|
|
|
+ console.log('handleChange',val)
|
|
|
}
|
|
|
-});
|
|
|
-
|
|
|
-const chartRef = ref<HTMLDivElement | null>(null);
|
|
|
-const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
|
|
|
-watch(
|
|
|
- () => props.propsData,
|
|
|
- (value) => {
|
|
|
+ function handlesetOptions() {
|
|
|
setOptions({
|
|
|
tooltip: {
|
|
|
trigger: 'axis',
|
|
|
axisPointer: {
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- backgroundColor: '#fff',
|
|
|
- color: '#556677',
|
|
|
- borderColor: 'rgba(0,0,0,0)',
|
|
|
- shadowColor: 'rgba(0,0,0,0)',
|
|
|
- shadowOffsetY: 0,
|
|
|
- },
|
|
|
lineStyle: {
|
|
|
- width: 0,
|
|
|
+ width: 1,
|
|
|
+ color: '#019680',
|
|
|
},
|
|
|
},
|
|
|
- backgroundColor: '#fff',
|
|
|
- textStyle: {
|
|
|
- color: '#5c6c7c',
|
|
|
- },
|
|
|
- padding: [10, 10],
|
|
|
- extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)',
|
|
|
},
|
|
|
-
|
|
|
- xAxis: [
|
|
|
- {
|
|
|
- type: 'category',
|
|
|
- data: props.xAxisData,
|
|
|
- axisLine: {
|
|
|
- lineStyle: {
|
|
|
- color: '#DCE2E8',
|
|
|
- },
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false,
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- interval: 0,
|
|
|
- textStyle: {
|
|
|
- color: '#556677',
|
|
|
- },
|
|
|
- // 默认x轴字体大小
|
|
|
- fontSize: 12,
|
|
|
- // margin:文字到x轴的距离
|
|
|
- margin: 15,
|
|
|
- },
|
|
|
- axisPointer: {
|
|
|
- label: {
|
|
|
- // padding: [11, 5, 7],
|
|
|
- padding: [0, 0, 10, 0],
|
|
|
- margin: 15,
|
|
|
- // 移入时的字体大小
|
|
|
- fontSize: 12,
|
|
|
- backgroundColor: {
|
|
|
- type: 'linear',
|
|
|
- x: 0,
|
|
|
- y: 0,
|
|
|
- x2: 0,
|
|
|
- y2: 1,
|
|
|
- colorStops: [
|
|
|
- {
|
|
|
- offset: 0,
|
|
|
- color: '#fff', // 0% 处的颜色
|
|
|
- },
|
|
|
- {
|
|
|
- // offset: 0.9,
|
|
|
- offset: 0.86,
|
|
|
- color: '#fff', // 0% 处的颜色
|
|
|
- },
|
|
|
- {
|
|
|
- offset: 0.86,
|
|
|
- color: '#33c0cd', // 0% 处的颜色
|
|
|
- },
|
|
|
- {
|
|
|
- offset: 1,
|
|
|
- color: '#33c0cd', // 100% 处的颜色
|
|
|
- },
|
|
|
- ],
|
|
|
- global: false, // 缺省为 false
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- boundaryGap: false,
|
|
|
- },
|
|
|
- ],
|
|
|
- yAxis: [
|
|
|
- {
|
|
|
- type: 'value',
|
|
|
- axisTick: {
|
|
|
- show: false,
|
|
|
- },
|
|
|
- splitLine: {
|
|
|
- show: true,
|
|
|
- lineStyle: {
|
|
|
- color: ['#f1f4f8'],
|
|
|
- width: 1,
|
|
|
- type: 'solid',
|
|
|
- },
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- textStyle: {
|
|
|
- color: '#556677',
|
|
|
- },
|
|
|
- formatter: '{value}',
|
|
|
- },
|
|
|
- axisLine: {
|
|
|
- show: false,
|
|
|
- lineStyle: {
|
|
|
- color: '#DCE2E8',
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
+ legend: {
|
|
|
+ orient: 'horizontal',
|
|
|
+ bottom: 0,
|
|
|
+ },
|
|
|
+ // grid: { left: '2%', right: '2%', top: '10%', bottom: '10%', containLabel: true },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ // data: [...new Array(30)].map((_item, index) => `${index + 1}日`),
|
|
|
+ data: yixStringData.value,
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: 'value',
|
|
|
+ max: maxSize.value,
|
|
|
+ splitNumber: 4,
|
|
|
+ },
|
|
|
series: [
|
|
|
{
|
|
|
- name: 'Adidas',
|
|
|
- type: 'line',
|
|
|
- data: [10, 10, 30, 12, 15, 3, 7],
|
|
|
- symbolSize: 1,
|
|
|
- symbol: 'circle',
|
|
|
- smooth: true,
|
|
|
- // yAxisIndex: 0,
|
|
|
- showSymbol: false,
|
|
|
- lineStyle: {
|
|
|
- width: 5,
|
|
|
- color: colorList[0],
|
|
|
- shadowColor: shadowColor[0],
|
|
|
- shadowBlur: 10,
|
|
|
- shadowOffsetY: 20,
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- // normal: {
|
|
|
- // color: colorList[0],
|
|
|
- // borderColor: colorList[0]
|
|
|
- // }
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'Nike',
|
|
|
- type: 'line',
|
|
|
- data: [5, 12, 11, 14, 25, 16, 10],
|
|
|
- symbolSize: 1,
|
|
|
- symbol: 'circle',
|
|
|
- smooth: true,
|
|
|
- // yAxisIndex: 0,
|
|
|
- showSymbol: false,
|
|
|
- lineStyle: {
|
|
|
- width: 5,
|
|
|
- color: colorList[1],
|
|
|
- shadowColor: shadowColor[1],
|
|
|
- shadowBlur: 10,
|
|
|
- shadowOffsetY: 20,
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- // normal: {
|
|
|
- // color: colorList[1],
|
|
|
- // borderColor: colorList[1]
|
|
|
- // }
|
|
|
- },
|
|
|
+ data: viewStaticsData.value,
|
|
|
+ type: 'bar',
|
|
|
+ itemStyle: { color: '#38a0ff' },
|
|
|
+ barMaxWidth: 80,
|
|
|
+ name: '用户浏览量',
|
|
|
},
|
|
|
{
|
|
|
- name: '老北京布鞋',
|
|
|
- type: 'line',
|
|
|
- data: [150, 120, 170, 140, 500, 160, 110],
|
|
|
- symbolSize: 1,
|
|
|
- // yAxisIndex: 1,
|
|
|
- symbol: 'circle',
|
|
|
- smooth: true,
|
|
|
- showSymbol: false,
|
|
|
- lineStyle: {
|
|
|
- width: 5,
|
|
|
- color: colorList[2],
|
|
|
- shadowColor: shadowColor[2],
|
|
|
- shadowBlur: 10,
|
|
|
- shadowOffsetY: 20,
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- // normal: {
|
|
|
- // color: colorList[2],
|
|
|
- // borderColor: colorList[2]
|
|
|
- // }
|
|
|
- },
|
|
|
+ data: shareStaticsData.value,
|
|
|
+ type: 'bar',
|
|
|
+ itemStyle: { color: '#4cca73' },
|
|
|
+ barMaxWidth: 80,
|
|
|
+ name: '用户分享数',
|
|
|
},
|
|
|
],
|
|
|
});
|
|
|
- },
|
|
|
- { immediate: true,deep:true },
|
|
|
-);
|
|
|
+ }
|
|
|
+ // props.viewStatics,
|
|
|
+ watch(
|
|
|
+ // () => [props.viewStatics, props.shareStatics],
|
|
|
+ // ([data1, data2]) => {
|
|
|
+ () => props.loading,
|
|
|
+ () => {
|
|
|
+ console.log('viewStatics-data');
|
|
|
+ // viewStaticsData.value = data1.reduce<number[]>(
|
|
|
+ // (prev: number[], current) => prev.concat(Number(current.amount)),
|
|
|
+ // [],
|
|
|
+ // );
|
|
|
+
|
|
|
+ // yixStringData.value = data1.reduce<string[]>(
|
|
|
+ // (prev: string[], current) => prev.concat(current.date),
|
|
|
+ // [],
|
|
|
+ // );
|
|
|
+ // shareStaticsData.value = data2.reduce<number[]>(
|
|
|
+ // (prev: number[], current) => prev.concat(Number(current.amount)),
|
|
|
+ // [],
|
|
|
+ // );
|
|
|
+
|
|
|
+ const maxNumber = Math.max(...viewStaticsData.value.concat(shareStaticsData.value));
|
|
|
+ const pow = Math.pow(10, maxNumber.toString().length - 1);
|
|
|
+ maxSize.value = maxNumber > 10 ? Math.floor(maxNumber / 10) * 10 + pow * 2 : 10;
|
|
|
+ console.log('maxSize', maxSize.value);
|
|
|
+ handlesetOptions();
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ );
|
|
|
</script>
|