【强力插件】Dashboard 数据面板 beta0.1

Innis 2022-1-7 1671

写在前面:

1. 这个插件只是非常初级的版本,希望大家多多包容,多多反馈哈

2. 该插件是在Hardy 和 花降 帮助下完成的,特别感谢~

3. 计划中这个插件有四个页面,目前只使用了一个,所以请大家大声说出你的需求,能加进去的肯定会实现。
目前已经收集到的需求:倒计时,时间块。

 

 

 

 

 

插件界面图:

 

界面介绍:

区域1:选项卡界面,点击可以切换选项卡,尚未完成

区域2:一些高频使用的数据

区域3:根据每天的使用度来生成的热点图

区域4:根据每天的使用时长来生成的折线图

区域5:根据所有主题的内容,分析出的词云

区域6:一些双链相关的数据

 

使用方法:

1.创建一个代码块 ( ```JavaScript )

2.把下方的文件复制到RE, 并点击右上角安装

3.确认安装

4.刷新

5.点击左上角图标,即可查看你的数据面板啦

 

6.enjoy~

 

注意:

有些时候因为一些依赖文件没有完全加载,会出现元素丢失和界面错乱的情况,这时候只需要刷新下界面就好。(资源是从外部加载进来的,所以网速慢的话,也会导致多次刷新无果,这时候,在错乱的窗口处停留10-30s等待加载,然后刷新即可。)

后续会修复该问题。

 

代码:

/**
 * @title Dashboard(仪表盘)
 * @author Innis
 * @note 你可以在这里看到你的数据和一些分析,帮助你更好的把握自己的知识,判断学习情况,并由此做出决策和行动。
 */

pluginManager.register('dashboard', {

    after_ui_run() {
        plugin.systabs.add("sample", "<i title=\"查看个人数据\" style=\"padding-top:5px\"><svg t='1641518206451'class='icon'viewBox='0 0 1024 1024'version='1.1'xmlns='http://www.w3.org/2000/svg'p-id='3631'width='20'height='20'><path d='M438.186667 572.928L128.426667 408.746667a79.616 79.616 0 0 1 0-140.672l309.76-164.181334a159.232 159.232 0 0 1 149.12 0l309.76 164.181334a79.616 79.616 0 0 1 0 140.672l-309.76 164.181333a159.232 159.232 0 0 1-149.12 0z'fill='#FFB531'p-id='3632'></path><path d='M512 938.666667a183.978667 183.978667 0 0 1-86.101333-21.418667L143.786667 767.744a111.36 111.36 0 0 1 0-196.821333 38.826667 38.826667 0 1 1 36.437333 68.608 33.706667 33.706667 0 0 0 0 59.52l282.026667 149.546666a106.069333 106.069333 0 0 0 99.498666 0l282.026667-149.546666a33.706667 33.706667 0 0 0 0-59.52 38.826667 38.826667 0 1 1 36.437333-68.608 111.36 111.36 0 0 1 0 196.821333l-282.112 149.504A183.978667 183.978667 0 0 1 512 938.666667z'fill='#030835'p-id='3633'></path></svg></i>", function () {

            JDialog.create({
                title: "Dashboard",
                width: 1020,
                height: 700,

                content: `<div id="dbd-container"><div id="dbd-sidebar"><div id="dbd-dashBoardIcon"class="dbd-sidebarIcons"><svg t="1641478347421"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="2272"width="32"height="32"><path d="M438.186667 572.928L128.426667 408.746667a79.616 79.616 0 0 1 0-140.672l309.76-164.181334a159.232 159.232 0 0 1 149.12 0l309.76 164.181334a79.616 79.616 0 0 1 0 140.672l-309.76 164.181333a159.232 159.232 0 0 1-149.12 0z"fill="#FFB531"p-id="2273"></path><path d="M512 938.666667a183.978667 183.978667 0 0 1-86.101333-21.418667L143.786667 767.744a111.36 111.36 0 0 1 0-196.821333 38.826667 38.826667 0 1 1 36.437333 68.608 33.706667 33.706667 0 0 0 0 59.52l282.026667 149.546666a106.069333 106.069333 0 0 0 99.498666 0l282.026667-149.546666a33.706667 33.706667 0 0 0 0-59.52 38.826667 38.826667 0 1 1 36.437333-68.608 111.36 111.36 0 0 1 0 196.821333l-282.112 149.504A183.978667 183.978667 0 0 1 512 938.666667z"fill="#030835"p-id="2274"></path></svg></div><div id="dbd-homeIcon"class="dbd-sidebarIcons"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><rect width="48"height="48"fill="white"fill-opacity="0.01"/><path d="M9 18V42H39V18L24 6L9 18Z"fill="none"/><path d="M9 42V18L4 22L24 6L44 22L39 18V42H9Z"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M19 29V42H29V29H19Z"fill="none"stroke="#ffffff"stroke-width="3"stroke-linejoin="round"/><path d="M9 42H39"stroke="#ffffff"stroke-width="3"stroke-linecap="round"/></svg></div><div id="dbd-todoIcon"class="dbd-sidebarIcons"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><rect width="48"height="48"fill="white"fill-opacity="0.01"/><path fill-rule="evenodd"clip-rule="evenodd"d="M6 42H42V6H32H30C28.6758 9.15854 26.6758 10.7378 24 10.7378C21.3242 10.7378 19.3242 9.15854 18 6H16H6V42Z"fill="none"stroke="#ffffff"stroke-width="3"stroke-linejoin="round"/><path d="M15 24L21 30L33 18"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/></svg></div><div id="dbd-textIcon"class="dbd-sidebarIcons"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><rect width="48"height="48"fill="white"fill-opacity="0.01"/><rect x="6"y="6"width="36"height="36"rx="3"fill="none"stroke="#ffffff"stroke-width="3"stroke-linejoin="round"/><path d="M16 19V16H32V19"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M22 34H26"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M24 18L24 34"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/></svg></div><div id="dbd-tomatoIcon"class="dbd-sidebarIcons"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><path d="M24 44C35.0457 44 44 36.6127 44 27.5C44 21.058 39.5252 15.7014 33 12.9842L29.5 14.5L30 20L23.5 18L17 20V14.5L14 12.9842C8.02199 15.8371 4 21.3927 4 27.5C4 36.6127 12.9543 44 24 44Z"fill="none"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M23.5 4L27.3088 9.11672L36 9.90983L29.6628 14.4833L31.5 21L23.5 18L15.5 21L17.3371 14.4833L11 9.90983L19.6911 9.11672L23.5 4Z"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/></svg></div></div><div id="dbd-leftbar"><div id="dbd-middle-top"><div id="dbd-chart1"class="dbd-chart"><div id="dbd-chart-days-words">使用天数</div><div id="dbd-chart-days-nums">9999</div></div><div id="dbd-chart2"class="dbd-chart"><div class="dbd-chart-words">节点总量</div><div class="dbd-chart-nums">9999</div><div id="dbdLineChartContainer2"><canvas id="dbdLineChart2"width="140"height="90"></canvas></div></div><div id="dbd-chart3"class="dbd-chart"><div class="dbd-chart-words">主题总量</div><div class="dbd-chart-nums">9999</div><div id="dbdLineChartContainer2"><canvas id="dbdLineChart3"width="140"height="90"></canvas></div></div><div id="dbd-chart4"class="dbd-chart"><div class="dbd-chart-words">文字总量</div><div class="dbd-chart-nums">9999</div><div id="dbdLineChartContainer2"><canvas id="dbdLineChart4"width="140"height="90"></canvas></div></div></div><div id="dbd-middle-middle"><div id="dbd-middle-middle-word">热力图</div><div id="cal-heatmap"></div></div><div id="dbd-middle-bottom"><div id="dbd-middle-bottom-word">数据概览</div><div id="dbdLinechart5Container"><canvas id="dbdLinechart5"width="600"height="200"></canvas></div></div></div><div id="dbd-rightbar"><div id="dbd-wordCloud"><canvas id="dbd-canvasWordCloud"width="300px"height="300px"></canvas></div><div id="dbd-infoArea"><div id="dbd-infoWord">双链数据</div><div id="dbd-links"class="dbd-infoArea"><div class="dbd-infoArea-icon"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><rect width="48"height="48"fill="white"fill-opacity="0.01"/><path d="M30 19H20C15.5817 19 12 22.5817 12 27C12 31.4183 15.5817 35 20 35H36C40.4183 35 44 31.4183 44 27C44 24.9711 43.2447 23.1186 42 21.7084"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M6 24.2916C4.75527 22.8814 4 21.0289 4 19C4 14.5817 7.58172 11 12 11H28C32.4183 11 36 14.5817 36 19C36 23.4183 32.4183 27 28 27H18"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/></svg></div><div class="dbd-infoArea-num">9999</div><div class="dbd-infoArea-word">双向链接</div></div><div id="dbd-refs"class="dbd-infoArea"><div class="dbd-infoArea-icon"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><path d="M11 34.6875L24 42L32 37.5L37 34.6875"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M40 30V15L27.5 7.96875"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M20.5 7.96875L8 15V30"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M21 18.75L18 20.5V24V27.5L21 29.25L24 31L27 29.25L30 27.5V24V20.5L27 18.75L24 17L21 18.75Z"fill="none"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M24 17V10"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M30 27L37 31"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M18 27L11 31"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><circle cx="24"cy="7"r="3"fill="none"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><circle cx="8"cy="33"r="3"fill="none"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><circle cx="40"cy="33"r="3"fill="none"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/></svg></div><div class="dbd-infoArea-num">9999</div><div class="dbd-infoArea-word">块引用数</div></div><div id="dbd-embeds"class="dbd-infoArea"><div class="dbd-infoArea-icon"><?xml version="1.0"encoding="UTF-8"?><svg width="32"height="32"viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"><rect width="48"height="48"fill="white"fill-opacity="0.01"/><path d="M30 17V4H4V30H17"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M43 43V17H17V43H43Z"fill="none"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M33 30L28 25M33 30L28 35M33 30H17"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/><path d="M17 17V43"stroke="#ffffff"stroke-width="3"stroke-linecap="round"stroke-linejoin="round"/></svg></div><div class="dbd-infoArea-num">9999</div><div class="dbd-infoArea-word">块嵌入数</div></div></div></div></div>`,
            });

            plugin.dashboard.dataInject();
            plugin.dashboard.chartDataInject()
            plugin.dashboard.wordCloud();
        }, 1002);

    },

    
    async Heatmap(heatmap, legend, start) {
        var cal = new CalHeatMap();
        cal.init({
            data: heatmap,
            itemSelector: '#cal-heatmap',
            itemNamespace: "cal",
            itemName: ["节点", "节点"],
            domain: 'month',
            subdomain: 'day',
            domainMargin: [5],
            tooltip: true,
            start: start,
            // start: new Date(2021, 4, 1),
            range: 8,
            cellSize: 8,
            highlight: 'now',
            weekStartOnMonday: false,
            considerMissingDataAsZero: true,
            domainLabelFormat: "%Y-%m",
            legend: legend,
            // legendColors: {
            //     min: "#fff",
            //     max: "#373f6e"
            // },
            // verticalOrientation: true,
            displayLegend: false,
            cellPadding: 4,
            domainDynamicDimension: true,
        });
    },

    BigChart(id, dayOfWeekLabels, datas) {
        var type = 'line';
        var data = {
            labels: dayOfWeekLabels,
            datasets: [
                {
                    label: "使用时长",
                    data: datas,
                    borderColor: "#656aad",
                    lineTension: 0.4,

                }
            ]
        };
        var options = {
            plugins: {
                legend: {
                    display: false,
                    labels: {
                        color: 'red'
                    }
                },
                title: {
                    display: false,
                    text: 'Custom Chart Title'
                }
            },
            scales: {
                x: {
                    display: false,
                },
                y: {

                    ticks: {
                        stepSize: 400,
                        color: "#9395b1"

                    },
                    grid: {
                        color: "black"
                    }
                },
            },
        };
        var ctx = document.getElementById(id).getContext('2d');
        var myChart = new Chart(ctx, {
            type: type,
            data: data,
            options: options,
        })
    },

    SmallChart(id, dayOfWeekLabels, data) {
        var type = 'line';
        var data = {
            labels: dayOfWeekLabels,
            datasets: [
                {
                    label: "数量",
                    data: data,
                    borderColor: "white",
                    borderWidth: 2,
                    lineTension: 0.5,
                    pointRadius: 2,
                }
            ]
        };
        var options = {
            plugins: {
                legend: {
                    display: false,
                },
            },
            scales: {
                x: {
                    display: false,
                },
                y: {
                    display: false,
                },
            },
        };
        var ctx = document.getElementById(id).getContext('2d');
        var dbdLineChart = new Chart(ctx, {
            type: type,
            data: data,
            options: options,
        })
    },

    wordCloud() {

        let data = plugin.memory.list;
        let topics = [];
        const regex = /\d{4}-\d{2}-\d{2}/g;
        for (let ele of data) {
            if (ele.topic != undefined && ele.topic != "untitled") {
                if (regex.test(ele.topic)) {
                    break
                } else {
                    topics.push(ele.topic);
                }
            }
        }
        topics = topics.join()

        const segmentit = Segmentit.useDefault(new Segmentit.Segment());
        const result = segmentit.doSegment(topics);

        let segmentWords = [];
        let rubbishKeyWord = [",", ",", "的", "个", "小", "也", ".", "。"]
        for (let ele of result) {
            if (rubbishKeyWord.includes(ele.w) != true) {
                segmentWords.push(ele.w);
            }
        }



        function getRepeatNum() {
            return segmentWords.reduce(function (prev, next) {
                prev[next] = (prev[next] + 1) || 1;
                return prev;
            }, {});
        }
        let sumRepeat = getRepeatNum()
        let wordcloudList = []
        for (var index in sumRepeat) {
            let sublist = [index, sumRepeat[index]]
            wordcloudList.push(sublist)

        }


        var wordFreqData = wordcloudList;
        var canvas = document.getElementById('dbd-canvasWordCloud');
        var options = eval({
            "list": wordFreqData,
            "gridSize": 6, // 密集程度 数字越小越密集
            "weightFactor": 20, // 字体大小=原始大小*weightFactor
            "maxFontSize": 60, //最大字号
            "minFontSize": 30, //最小字号
            "fontWeight": 'normal', //字体粗细
            "fontFamily": 'Times, serif', // 字体
            "color": 'random-light', // 字体颜色 'random-dark' 或者 'random-light'
            "backgroundColor": '#464e89', // 背景颜色
            "rotateRatio": 0, // 字体倾斜(旋转)概率,1代表总是倾斜(旋转)
            // https://github.com/timdream/wordcloud2.js/blob/gh-pages/API.md
        });
        //生成
        WordCloud(canvas, options);
    },

    fields: {
        bullets: {
            label: "Bullet数",
            stat: 0,
        },
        topics: {
            label: "主题数",
            stat: 0,
            data: {}
        },
        emptyTopics: {
            label: "空主题数",
            stat: 0
        },
        keywords: {
            label: "关键词",
            data: {}
        },
        chars: {
            stat: 0
        },
        words: {
            label: "字数",
            stat: 0,
            data: {}
        },
        mentions: {
            label: "双向链接",
            stat: 0
        },
        referText: {
            label: "块引用",
            stat: 0
        },
        referBlock: {
            label: "块嵌入",
            stat: 0
        },
        timerecord: {
            //label: "编辑时长",
            stat: 0,
            data: {}
        },
        days: {
            label: "使用天数",
            help: "实际有使用 RoamEdit 的天数",
            data: {},
            stat: 0
        },
        hour: {
            data: {},
            stat: 0
        },
        range: {
            label: "时段节点数",
            data: {
                "0~5": 0,
                "6~10": 0,
                "11~13": 0,
                "14~19": 0,
                "20~23": 0
            }
        }
    },

    analysis() {
        let bulletList = plugin.memory.list;
        const info = deepClone(plugin.dashboard.fields);
        for (const item of bulletList) {
            const created = timekit.format("yyyy-MM-dd", item.created);
            info.days.data[created] = info.days.data[created] || 0;
            info.days.data[created] += 1;

            const updated = timekit.format("yyyy-MM-dd", item.updated);
            if (updated !== created) {
                info.days.data[updated] = info.days.data[updated] || 0;
                info.days.data[updated] += 1;
            }

            let hour = timekit.format("h", item.created);
            info.hour.data[hour] = info.hour.data[hour] || 0;
            info.hour.data[hour] += 1;
            Object.keys(info.range.data).forEach(k => {
                let [start, end] = k.split("~");
                start = parseInt(start);
                end = parseInt(end);
                if (hour >= start && hour <= end) {
                    info.range.data[k] += 1;
                }
            });

            let hour2 = timekit.format("h", item.updated);
            if (hour2 !== hour) {
                info.hour.data[hour2] = info.hour.data[hour2] || 0;
                info.hour.data[hour2] += 1;
                Object.keys(info.range).forEach(k => {
                    let [start, end] = k.split("~");
                    start = parseInt(start);
                    end = parseInt(end);
                    if (hour2 >= start && hour2 <= end) {
                        info.range.data[k] += 1;
                    }
                });
            }

            if (typeof item.ori === "string") {
                info.chars.stat += item.ori.length;
            }

            if (pluginManager.isPlgEnabled("counter")) {
                info.words.stat += plugin.counter.bulletWords(item);
                const created = timekit.format("yyyy-MM-dd", item.created);
                info.words.data[created] = info.words.data[created] || 0;
                info.words.data[created] += plugin.counter.bulletWords(item);

                const updated = timekit.format("yyyy-MM-dd", item.updated);
                if (updated !== created) {
                    info.words.data[updated] = info.words.data[updated] || 0;
                    info.words.data[updated] += plugin.counter.bulletWords(item);
                }
            }

            if (typeof item.topic === "string") {
                info.topics.stat += 1;
                const created = timekit.format("yyyy-MM-dd", item.created);
                info.topics.data[created] = info.topics.data[created] || 0;
                info.topics.data[created] += 1;

                const updated = timekit.format("yyyy-MM-dd", item.updated);
                if (updated !== created) {
                    info.topics.data[updated] = info.topics.data[updated] || 0;
                    info.topics.data[updated] += 1;
                }


                if (plugin.memory.indexed.path[item.ky] && Object.keys(plugin.memory.indexed.path[item.ky]).length < 2) {
                    info.emptyTopics.stat += 1;
                }
            }

            if (!isEmpty(item.referText)) {
                info.referText.stat += item.referText.length;
            }

            if (!isEmpty(item.referBlock)) {
                info.referBlock.stat += 1;
            }

            if (typeof item.mentions === "object") {
                info.mentions.stat += item.mentions.length;
                item.mentions.forEach(m => {
                    info.keywords.data[m] = info.keywords.data[m] || 0;
                    info.keywords.data[m] += 1;
                });
            }

            if (typeof item.timerecord === "number") {
                info.timerecord.stat += item.timerecord;
                const created = timekit.format("yyyy-MM-dd", item.created);
                info.timerecord.data[created] = info.timerecord[created] || 0;
                info.timerecord.data[created] += item.timerecord;

                const updated = timekit.format("yyyy-MM-dd", item.updated);
                if (updated !== created) {
                    info.timerecord.data[updated] = info.timerecord.data[updated] || 0;
                    info.timerecord.data[updated] += item.timerecord;
                }
            }
        }
        info.days.stat = Object.keys(info.days.data).length;
        info.range.stat = info.range.data;
        info.keywords.stat = Object.keys(info.keywords.data).length;
        info.timerecord.stat = Math.round(info.timerecord / 3600) + "h";
        info.bullets.stat = bulletList.length;

        return info
    },

    dataInject() {
        let info = plugin.dashboard.analysis()

        $("#dbd-chart-days-nums").html(info.days.stat);
        $("#dbd-chart2 .dbd-chart-nums").html(info.bullets.stat);
        $("#dbd-chart3 .dbd-chart-nums").html(info.topics.stat);
        $("#dbd-chart4 .dbd-chart-nums").html(info.words.stat);
        $("#dbd-links .dbd-infoArea-num").html(info.mentions.stat);
        $("#dbd-refs .dbd-infoArea-num").html(info.referText.stat);
        $("#dbd-embeds .dbd-infoArea-num").html(info.referBlock.stat);

        let heatmapData = info.days.data
        let heatmap = {};
        let legendMax = 0;
        let legendMin = 9999999;
        for (var index in heatmapData) {
            var date = new Date(index);
            var timestamp = date.getTime() / 1000;
            heatmap[timestamp] = heatmapData[index];

            if (heatmapData[index] > legendMax) {
                legendMax = heatmapData[index];
            };
            if (heatmapData[index] < legendMin) {
                legendMin = heatmapData[index];
            };
        }
        let mediumNum1 = (legendMax - legendMin) / 3 + legendMin;
        let mediumNum2 = 2 * (legendMax - legendMin) / 3 + legendMin;
        let legend = [parseInt(legendMin), parseInt(mediumNum1) + 1, parseInt(mediumNum2), parseInt(legendMax) + 1]
        var dt = new Date();
        let start = dt.setMonth(dt.getMonth() - 7);
        plugin.dashboard.Heatmap(heatmap, legend, start)
    },

    chartDataInject() {

        let dayOfWeeks = plugin.dashboard.getDateListAndDayOfWeekList("dayList", 7);
        let preDates = plugin.dashboard.getDateListAndDayOfWeekList("dateList", 7);

        let bigChartDates = plugin.dashboard.getDateListAndDayOfWeekList("dateList", 14);

        let info = plugin.dashboard.analysis()
        let nodeNumList = info.days.data
        let topicNumList = info.topics.data
        let WordNumList = info.words.data
        let timeRecordList = info.timerecord.data

        nodeNumList = plugin.dashboard.turnObjToList(nodeNumList, preDates, 7)
        topicNumList = plugin.dashboard.turnObjToList(topicNumList, preDates, 7)
        WordNumList = plugin.dashboard.turnObjToList(WordNumList, preDates, 7)
        timeRecordList = plugin.dashboard.turnObjToList(timeRecordList, bigChartDates, 14)

        plugin.dashboard.SmallChart("dbdLineChart2", dayOfWeeks, nodeNumList);
        plugin.dashboard.SmallChart("dbdLineChart3", dayOfWeeks, topicNumList);
        plugin.dashboard.SmallChart("dbdLineChart4", dayOfWeeks, WordNumList);
        plugin.dashboard.BigChart("dbdLinechart5", bigChartDates, timeRecordList);

    },

    turnObjToList(object, timeRangeList, range) {
        let list = [];
        let i = 0;
        for (i = 0; i < range; i++) {
            if (object[timeRangeList[i]]) {
                list.push(object[timeRangeList[i]])
            } else {
                list.push(0)
            }
        }
        return list
    },

    turnNumToDayofWeek(dayList, range) {
        let list = []
        for (let i = 0; i < range; i++) {
            switch (dayList[i]) {
                case 0:
                    list.push("周日");
                    break;
                case 1:
                    list.push("周一");
                    break;
                case 2:
                    list.push("周二");
                    break;
                case 3:
                    list.push("周三");
                    break;
                case 4:
                    list.push("周四");
                    break;
                case 5:
                    list.push("周五");
                    break;
                case 6:
                    list.push("周六");
                    break;
            }
        }
        return list
    },

    getDateListAndDayOfWeekList(mode, range) {
        let today = new Date();
        let preDates = [];
        let dayOfWeeks = [];
        for (let i = range - 1; i > -1; i--) {
            let preDate = new Date(today.getTime() - i * 24 * 60 * 60 * 1000);
            let dayOfWeek = preDate.getDay();
            dayOfWeeks.push(dayOfWeek)
            preDate = timekit.format("yyyy-MM-dd", preDate);
            preDates.push(preDate)
        }
        dayOfWeeks = plugin.dashboard.turnNumToDayofWeek(dayOfWeeks, 14)
        if (mode == "dateList") {
            return preDates
        } else if (mode == "dayList") {
            return dayOfWeeks
        }

    },
    run() {
        loadScript("https://cdn.bootcdn.net/ajax/libs/Chart.js/3.7.0/chart.js");//chartjs
        loadScript("https://cdn.jsdelivr.net/npm/segmentit@2.0.3/dist/umd/segmentit.js");//分词
        loadScript("https://cdn.bootcdn.net/ajax/libs/wordcloud2.js/1.2.2/wordcloud2.min.js");//词云
        loadCss("https://club.roamedit.com/dev/dashBoard/dashBoard.css");
        loadScript("https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js");//热点图
        loadScript("https://cdn.bootcdn.net/ajax/libs/cal-heatmap/3.6.2/cal-heatmap.min.js");//热点图

    }
});
快速回复
最新回复 (16)
  • leo 2022-1-7
    0 2
    强!
  • leo 2022-1-7
    0 3
    可以复制到自定义js窗口里面吗?
  • Innis 2022-1-7
    0 4
    不行的,那样没法加载CSS,会导致整个页面都会乱掉😂
  • Hardy 2022-1-7
    0 5
    非常精彩
  • 泉毅 2022-1-7
    2 6

    建议1:仪表盘顶部希望可以添加【最大化】【最小化】按钮,方便不看时,可以收起来。

    需求:希望有项目进度数据统计视图,如下图这种形式。

  • kevin 2022-1-26
    0 7
    数据面板乱码,不知道如何解决
  • zdq_1230 2022-1-26
    0 8
    没看见安装字样,是复制的不对?
  • sheen 2022-1-26
    0 9
    zdq_1230 没看见安装字样,是复制的不对?
    截图发出来吧
  • zdq_1230 2022-1-26
    0 10

  • zdq_1230 2022-1-26
    0 11
    新手一个,考虑入手个永久版,正在熟悉中。是按代码复制吧?
  • zdq_1230 2022-1-26
    0 12
    我用的是Vivaldi浏览器
  • sheen 2022-1-27
    0 13
    zdq_1230
    不是这样安装JS代码块的
    看下这个教程:https://www.bilibili.com/video/BV1vf4y1G7nH/
  • pilgrim112 2022-1-28
    0 14
    我看到最新的更新通知,这个插件是已经内置了吗?但是在插件中心没看到。
  • zdq_1230 2022-2-1
    0 15

  • zdq_1230 2022-2-1
    0 16

  • zdq_1230 2022-2-1
    0 17
    现在安装不显示错误,但刷新后没有那个图标按钮
返回