improve-gantt-elastic(vue2中甘特圖實現與引入)

1.前言

????????項目開發中需要使用甘特圖展示項目實施進度,左側為表格計劃,右側為圖表進度展示。wl-gantt-mater,dhtmlx嘗試使用過可拓展性受到限制。gantt-elastic相對簡單,可操作性強,基礎版本免費。

????????甘特圖(Gantt chart)又稱為橫道圖、條狀圖(Bar chart),通過條狀圖來顯示項目、進度和其他時間相關的系統進展的內在關系隨著時間進展的情況。以提出者亨利·勞倫斯·甘特(Henry Laurence Gantt)先生的名字命名。

2.?gantt-elastic(vue2中甘特圖實現與引入)

2.1?gantt-elastic

官方demo

?gantt-elastic官網gantt-elastic | Gantt Chart [ javascript gantt chart, gantt component, vue gantt, vue gantt chart, responsive gantt, project manager , vue projects ]icon-default.png?t=O83Ahttps://neuronetio.github.io/gantt-elastic/

2.2 npm install引入

不受網絡限制直接npm install在項目中

npm install --save gantt-elastic
npm install --save gantt-elastic-header # 可選,根據需求安裝

將對應的demo組件引入對應的項目。?

2.3內網引入

(1)拉取github上的gantt-elastic項目

將對應需要的依賴進行復制到需要開發的項目依賴中node_module。

需要復制的依賴包,相關依賴包已上傳到博客資源中,可自行下載使用。

dayjs  
gantt-elastic  
gantt-elastic-header  
resize-observe-polyfill  
vue-slider-component  
vue-switches

(2) package.json版本鎖定

"dependencies": {"dayjs": "^1.8.14","gantt-elastic": "^1.0.12","gantt-elastic-header": "^0.1.11",
}

(3) demo引入

<template><gantt-elastic:options="options":tasks="tasks"@tasks-changed="tasksUpdate"@options-changed="optionsUpdate"@dynamic-style-changed="styleUpdate"><gantt-header slot="header"></gantt-header></gantt-elastic>
</template><script>
import GanttElastic from "gantt-elastic";
import GanttHeader from "gantt-elastic-header";
import dayjs from "dayjs";// just helper to get current dates
function getDate(hours) {const currentDate = new Date();const currentYear = currentDate.getFullYear();const currentMonth = currentDate.getMonth();const currentDay = currentDate.getDate();const timeStamp = new Date(currentYear,currentMonth,currentDay,0,0,0).getTime();return new Date(timeStamp + hours * 60 * 60 * 1000).getTime();
}let tasks = [{id: 1,label: "Make some noise",user:'<a href="https://www.google.com/search?q=John+Doe" target="_blank" style="color:#0077c0;">John Doe</a>',start: getDate(-24 * 5),duration: 15 * 24 * 60 * 60 * 1000,percent: 85,type: "project",collapsed: true,},{id: 2,label: "With great power comes great responsibility",user:'<a href="https://www.google.com/search?q=Peter+Parker" target="_blank" style="color:#0077c0;">Peter Parker</a>',parentId: 1,start: getDate(-24 * 4),duration: 4 * 24 * 60 * 60 * 1000,percent: 50,type: "milestone",collapsed: true,style: {base: {fill: "#1EBC61",stroke: "#0EAC51"}}},{id: 3,label: "Courage is being scared to death, but saddling up anyway.",user:'<a href="https://www.google.com/search?q=John+Wayne" target="_blank" style="color:#0077c0;">John Wayne</a>',parentId: 2,start: getDate(-24 * 3),duration: 2 * 24 * 60 * 60 * 1000,percent: 100,type: "task"},{id: 4,label: "Put that toy AWAY!",user:'<a href="https://www.google.com/search?q=Clark+Kent" target="_blank" style="color:#0077c0;">Clark Kent</a>',start: getDate(-24 * 2),duration: 2 * 24 * 60 * 60 * 1000,percent: 50,type: "task",dependentOn: [3]},{id: 5,label:"One billion, gajillion, fafillion... shabadylu...mil...shabady......uh, Yen.",user:'<a href="https://www.google.com/search?q=Austin+Powers" target="_blank" style="color:#0077c0;">Austin Powers</a>',parentId: 4,start: getDate(0),duration: 2 * 24 * 60 * 60 * 1000,percent: 10,type: "milestone",style: {base: {fill: "#0287D0",stroke: "#0077C0"}}},{id: 6,label: "Butch Mario and the Luigi Kid",user:'<a href="https://www.google.com/search?q=Mario+Bros" target="_blank" style="color:#0077c0;">Mario Bros</a>',parentId: 5,start: getDate(24),duration: 1 * 24 * 60 * 60 * 1000,percent: 50,type: "task",collapsed: true,style: {base: {fill: "#8E44AD",stroke: "#7E349D"}}},{id: 7,label: "Devon, the old man wanted me, it was his dying request",user:'<a href="https://www.google.com/search?q=Knight+Rider" target="_blank" style="color:#0077c0;">Knight Rider</a>',parentId: 2,dependentOn: [6],start: getDate(24 * 2),duration: 4 * 60 * 60 * 1000,percent: 20,type: "task",collapsed: true},{id: 8,label: "Hey, Baby! Anybody ever tell you I have beautiful eyes?",user:'<a href="https://www.google.com/search?q=Johhny+Bravo" target="_blank" style="color:#0077c0;">Johhny Bravo</a>',parentId: 7,dependentOn: [7],start: getDate(24 * 3),duration: 1 * 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 9,label:"This better be important, woman. You are interrupting my very delicate calculations.",user:'<a href="https://www.google.com/search?q=Dexter\'s+Laboratory" target="_blank" style="color:#0077c0;">Dexter\'s Laboratory</a>',parentId: 8,dependentOn: [8, 7],start: getDate(24 * 4),duration: 4 * 60 * 60 * 1000,percent: 20,type: "task",style: {base: {fill: "#8E44AD",stroke: "#7E349D"}}},{id: 10,label: "current task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 5),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 11,label:"test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 6),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 12,label: "test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 7),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task",parentId: 11},{id: 13,label:"test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 8),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 14,label: "test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 9),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 15,label: "test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 16),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"}];let options = {taskMapping: {progress: "percent"},maxRows: 100,maxHeight: 500,title: {label: "Your project title as html (link or whatever...)",html: false},row: {height: 24},calendar: {hour: {display: true}},chart: {progress: {bar: false},expander: {display: true}},taskList: {expander: {straight: false},columns: [{id: 1,label: "ID",value: "id",width: 40},{id: 2,label: "Description",value: "label",width: 200,expander: true,html: true,events: {click({ data, column }) {alert("description clicked!\n" + data.label);}}},{id: 3,label: "Assigned to",value: "user",width: 130,html: true},{id: 3,label: "Start",value: task => dayjs(task.start).format("YYYY-MM-DD"),width: 78}, {id: 4,label: "Type",value: "type",width: 68},{id: 5,label: "%",value: "progress",width: 35,style: {"task-list-header-label": {"text-align": "center",width: "100%"},"task-list-item-value-container": {"text-align": "center",width: "100%"}}}]},locale: {name: "en",Now: "Now","X-Scale": "Zoom-X","Y-Scale": "Zoom-Y","Task list width": "Task list","Before/After": "Expand","Display task list": "Task list"}};export default {name: "Gantt",components: {GanttElastic,GanttHeader},data() {return {tasks,options,dynamicStyle: {},lastId: 16};},methods: {tasksUpdate(tasks) {this.tasks = tasks;},optionsUpdate(options) {this.options = options;},styleUpdate(style) {this.dynamicStyle = style;}}
};
</script><style>
</style>

3.gantt-elastic-h

基于?gantt-elastic的拓展封裝,基本功能相較gantt-elastic完善。在使用gantt-elastic可參考gantt-elastic-h的Api文檔。也可選擇使用gantt-elastic-h來實現參考使用文檔自行完成。

使用文檔 | gantt-elastic-h | 使用文檔icon-default.png?t=O83Ahttps://jianguoht.github.io/gantt-elastic-h/doc.html#options-tasklist-columns

4.參考博客

vue甘特圖(內網引入gantt-elastic以及源碼擴展)_vue wl-gantt-CSDN博客文章瀏覽閱讀3.2k次,點贊2次,收藏18次。前言:項目要求用甘特圖展示計劃的實施過程。之前用過dhtmlx,用著不是很舒服。又在網上看了jQueryGantt-master,wl-gantt-mater,gantt-elastic的大概源碼,最后選定gantt-elastic(源碼相對簡單,易擴展開發,沒選用他的進階版本gantt-schedule-timeline-calendar-master的原因是這個要收費)1.外網開發,直接去github上npm install就好,我是內網開發,在github上install下來,然后把下下來的nod_vue wl-gantthttps://blog.csdn.net/qq_36566924/article/details/125293765?fromshare=blogdetail&sharetype=blogdetail&sharerId=125293765&sharerefer=PC&sharesource=2301_76671906&sharefrom=from_link

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/66007.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/66007.shtml
英文地址,請注明出處:http://en.pswp.cn/web/66007.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

力扣 全排列

回溯經典例題。 題目 通過回溯生成所有可能的排列。每次遞歸時&#xff0c;選擇一個數字&#xff0c;直到選滿所有數字&#xff0c;然后記錄當前排列&#xff0c;回到上層時移除最后選的數字并繼續選擇其他未選的數字。每次遞歸時&#xff0c;在 path 中添加一個新的數字&…

1/13+2

運算符重載 myString.h #ifndef MYSTRING_H #define MYSTRING_H #include <cstring> #include <iostream> using namespace std; class myString {private:char *str; //記錄c風格的字符串int size; //記錄字符串的實際長度int capacity; …

04.計算機體系三層結構與優化(操作系統、計算機網絡、)

3.計算機體系三層結構與優化&#xff08;day04&#xff09; 3.1 操作系統 內容概要&#xff1a; 操作系統的發展史&#xff1a;批處理系統》分時操作系統》unix>linux多道技術》&#xff08;進程、線程&#xff09;并發進程與線程相關概念任務運行的三種狀態&#xff1a;…

【HM-React】08. Layout模塊

基本結構和樣式reset 結構創建 實現步驟 打開 antd/Layout 布局組件文檔&#xff0c;找到示例&#xff1a;頂部-側邊布局-通欄拷貝示例代碼到我們的 Layout 頁面中分析并調整頁面布局 代碼實現 pages/Layout/index.js import { Layout, Menu, Popconfirm } from antd impor…

計算機視覺算法實戰——實時車輛檢測和分類(主頁有相關源碼)

?個人主頁歡迎您的訪問 ?期待您的三連 ? ?個人主頁歡迎您的訪問 ?期待您的三連 ? ?個人主頁歡迎您的訪問 ?期待您的三連? ? ?????????????????? 1. 領域介紹?? 實時車輛檢測和分類是計算機視覺中的一個重要應用領域&#xff0c;旨在從視頻流或…

使用 selenium-webdriver 開發 Web 自動 UI 測試程序

優缺點 優點 有時候有可能一個改動導致其他的地方的功能失去效果&#xff0c;這樣使用 Web 自動 UI 測試程序可以快速的檢查并定位問題&#xff0c;節省大量的人工驗證時間 缺點 增加了維護成本&#xff0c;如果功能更新過快或者技術更新過快&#xff0c;維護成本也會隨之提高…

性能測試工具Jmeter分布式運行

性能測試工具JMeter的分布式執行是一種用于增強壓力測試能力的技術方案&#xff0c;它允許用戶通過多臺機器來共同完成同一個測試計劃的執行。這種方式特別適用于需要模擬成百上千甚至上萬用戶并發訪問的情況&#xff0c;當單臺機器由于硬件資源&#xff08;如CPU、內存、網絡I…

彌散張量分析開源軟件 DSI Studio 簡體中文漢化版可以下載了

網址&#xff1a; (63條消息) DSIStudio簡體中文漢化版(2022年7月)-算法與數據結構文檔類資源-CSDN文庫

移動云自研云原生數據庫入圍國采!

近日&#xff0c;中央國家機關2024年度事務型數據庫軟件框架協議聯合征集采購項目產品名單正式公布&#xff0c;移動云自主研發的云原生數據庫產品順利入圍。這一成就不僅彰顯了移動云在數據庫領域深耕多年造就的領先技術優勢&#xff0c;更標志著國家權威評審機構對移動云在數…

在vscode中使用R-1

參考我的上一篇博客&#xff1a; https://blog.csdn.net/weixin_62528784/article/details/145092632?spm1001.2014.3001.5501 這篇內容實際上就是上一篇博客的后續承接&#xff0c;既然都在vscode的jupyter中使用R了&#xff0c;實際上其實也能夠直接在vscode中原生使用R的編…

【Block總結】掩碼窗口自注意力 (M-WSA)

摘要 論文鏈接&#xff1a;https://arxiv.org/pdf/2404.07846 論文標題&#xff1a;Transformer-Based Blind-Spot Network for Self-Supervised Image Denoising Masked Window-Based Self-Attention (M-WSA) 是一種新穎的自注意力機制&#xff0c;旨在解決傳統自注意力方法在…

【Linux】統信UOS服務器安裝MySQL8.0(RPM)

目錄 一、下載安裝包 二、安裝MySQL 2.1hive適配 2.2ranger適配 3.2DolphinScheduler適配 一、下載安裝包 官網下載安裝包&#xff1a;MySQL :: MySQL Downloads 選擇社區版本下載 點擊MySQL Community Server 選擇對應系統的MySQL版本號 統信1060a 操作系統對應 redhat8…

小白:react antd 搭建框架關于 RangePicker DatePicker 時間組件使用記錄 2

文章目錄 一、 關于 RangePicker 組件返回的moment 方法示例 一、 關于 RangePicker 組件返回的moment 方法示例 moment方法中日后開發有用的方法如下&#xff1a; form.getFieldsValue().date[0].weeksInWeekYear(),form.getFieldsValue().date[0].zoneName(), form.getFiel…

Jenkins簡單的安裝運行

一、下載 官網下載&#xff1a;https://www.jenkins.io/download/ 清華大學開源軟件鏡像站&#xff1a;https://mirrors.tuna.tsinghua.edu.cn/jenkins/ 官網資料豐富&#xff0c;介紹了各種平臺安裝以及下載。安裝簡單&#xff0c;按照說明來就行。下面我介紹一個非常簡單的…

【CSS】HTML頁面定位CSS - position 屬性 relative 、absolute、fixed 、sticky

目錄 relative 相對定位 absolute 絕對定位 fixed 固定定位 sticky 粘性定位 position&#xff1a;relative 、absolute、fixed 、sticky &#xff08;四選一&#xff09; top&#xff1a;距離上面的像素 bottom&#xff1a;距離底部的像素 left&#xff1a;距離左邊的像素…

網絡安全 | WAF防護開通流程與技術原理詳解

關注&#xff1a;CodingTechWork 引言 隨著互聯網安全形勢的日益嚴峻&#xff0c;Web應用防火墻&#xff08;WAF, Web Application Firewall&#xff09;逐漸成為網站和應用的標準防護措施。WAF能夠有效識別和防止如SQL注入、跨站腳本攻擊&#xff08;XSS&#xff09;、惡意流…

小結:路由器和交換機的指令對比

路由器和交換機的指令有一定的相似性&#xff0c;但也有明顯的區別。以下是兩者指令的對比和主要差異&#xff1a; 相似之處 基本操作 兩者都支持類似的基本管理命令&#xff0c;比如&#xff1a; 進入系統視圖&#xff1a;system-view查看當前配置&#xff1a;display current…

Ubuntu中雙擊自動運行shell腳本

方法1: 修改文件雙擊反應 參考: https://blog.csdn.net/miffywm/article/details/103382405 chmod x test.sh鼠標選中待執行文件&#xff0c;在窗口左上角edit菜單中選擇preference設計雙擊執行快捷鍵&#xff0c;如下圖&#xff1a; 方法2: 設置一個應用 參考: https://blo…

從0開始學習搭網站的第一天

前言&#xff0c;以下內容學習自mdn社區&#xff0c;感興趣的朋友可以直接去看原文章web技術 目錄 web機制互聯網是怎么運作的網站服務器是什么什么是URL&#xff1f;什么是web服務器&#xff1f;什么是域名什么是超鏈接什么是網頁DOMgoole瀏覽器開發者工具 web機制 互聯網是怎…

java小灶課詳解:關于char和string的區別和對應的詳細操作

char和string的區別與操作詳解 在編程語言中&#xff0c;char和string是用于處理字符和字符串的兩種重要數據類型。它們在存儲、操作和應用場景上存在顯著差異。本文將從以下幾個方面詳細解析兩者的區別及常見操作。 1. 基本定義與存儲差異 char&#xff1a; 定義&#xff1a;…