Browse Source

add new

master
panda 8 months ago
parent
commit
4cc6cb10ee
  1. 53
      src/components/blogs/HomePage.vue
  2. 4
      src/hooks/intex.ts

53
src/components/blogs/HomePage.vue

@ -429,7 +429,6 @@ const statistics = reactive([
]) ])
// //
const heat = ref(null); const heat = ref(null);
const newData = <any>[];
function generateDates(numDays: number) { function generateDates(numDays: number) {
const dates = []; const dates = [];
@ -446,18 +445,37 @@ function generateDates(numDays: number) {
// 60 // 60
const data = generateDates(60); const data = generateDates(60);
// //
const rawData = ref<any[]>([]);
const statisticList = async () => {
await get("/statistics/list").then(response => {
rawData.value = response.data.data
rawData.value.forEach(newDataItem => {
const item = newData.find((d: any) => d.date === newDataItem.date);
if (item) {
item.writCount = newDataItem.writCount;
}
});
let formattedData = newData.map((item: any, index: number) => {
return [index % 15, Math.floor(index / 15), item.writCount]
});
console.log(formattedData, "form");
formattedList(formattedData)
createEcharts(heat, heatMapData);
})
}
const formattedList = (val: any) => {
heatMapData.series[0].data = val
}
const newData = <any>[];
for (let i = 0; i < 60; i += 15) { for (let i = 0; i < 60; i += 15) {
// 15 // 15
const chunk = data.slice(i, i + 15).reverse(); const chunk = data.slice(i, i + 15).reverse();
newData.push(...chunk); newData.push(...chunk);
} }
const rawData = ref<any[]>([]);
const formattedData = newData.map((item: any, index: number) => {
return [index % 15, Math.floor(index / 15), item.writCount]
});
const heatMapData = {
const heatMapData = reactive(
{
tooltip: { tooltip: {
position: 'top', position: 'top',
formatter: function (params: any) { formatter: function (params: any) {
@ -500,15 +518,16 @@ const heatMapData = {
bottom: '15%', bottom: '15%',
show: false, show: false,
inRange: { inRange: {
color: ['rgba(182,181,178,0.01)', 'rgb(157,156,153,1)'] // 0, 0
color: ['rgba(182,181,178,0.01)', 'rgba(157,156,153,1)'] // 0, 0
} }
}, },
series: [{ series: [{
type: 'heatmap', type: 'heatmap',
data: formattedData,
data: [],
itemStyle: { itemStyle: {
borderColor: 'rgb(231,229,225,0.5)', // borderColor: 'rgb(231,229,225,0.5)', //
borderWidth: 0.5, // borderWidth: 0.5, //
}, },
label: { label: {
show: false, show: false,
@ -522,19 +541,8 @@ const heatMapData = {
} }
} }
}] }]
};
const statisticList = async () => {
await get("/statistics/list").then(response => {
rawData.value = response.data.data
rawData.value.forEach(newDataItem => {
const item = newData.find((d: any) => d.date === newDataItem.date);
if (item) {
item.writCount = newDataItem.writCount;
}
});
})
} }
)
// //
const random = ref(); const random = ref();
@ -548,6 +556,7 @@ onMounted(() => {
statisticList() statisticList()
updateCurrentDate(); updateCurrentDate();
setInterval(updateCurrentDate, 24 * 60 * 60 * 1000); setInterval(updateCurrentDate, 24 * 60 * 60 * 1000);
createEcharts(heat, heatMapData);
nextTick(() => { nextTick(() => {
const authorElement = document.querySelector('.author'); const authorElement = document.querySelector('.author');
if (authorElement) { if (authorElement) {
@ -609,11 +618,9 @@ onMounted(() => {
} }
}); });
scrollbar.value = document.querySelector('.simplebar-content-wrapper'); scrollbar.value = document.querySelector('.simplebar-content-wrapper');
createEcharts(heat, heatMapData);
})
})
watch( watch(
() => route.name, () => route.name,
(newRouteName) => { (newRouteName) => {

4
src/hooks/intex.ts

@ -45,6 +45,10 @@ export const verifySelect = (message: selectMessage) => {
* echarts配置 * echarts配置
*/ */
export const createEcharts = (chartRef: any, option: any) => { export const createEcharts = (chartRef: any, option: any) => {
console.log(option,1111111111);
setTimeout(() => {
console.log(option.series[0].data,22222222);
}, 1000);
const myChart = echarts.init(chartRef.value); const myChart = echarts.init(chartRef.value);
myChart.setOption(option); myChart.setOption(option);
}; };
Loading…
Cancel
Save