首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >组件分享之前端组件——甘特图时间表时间线日历组件

组件分享之前端组件——甘特图时间表时间线日历组件

作者头像
cn華少
发布于 2022-03-06 01:17:25
发布于 2022-03-06 01:17:25
2.4K00
代码可运行
举报
文章被收录于专栏:IT综合技术分享IT综合技术分享
运行总次数:0
代码可运行

组件分享之前端组件——甘特图时间表时间线日历组件

背景

近期正在探索前端、后端、系统端各类常用组件与工具,对其一些常见的组件进行再次整理一下,形成标准化组件专题,后续该专题将包含各类语言中的一些常用组件。欢迎大家进行持续关注。

组件基本信息

内容

本次分享的组件是甘特图时间表时间线日历组件

Gantt-elastic -Javascript 甘特图(可编辑,响应式) vue、jquery、vanilla js等框架的Javascript甘特图

其后续延伸的组件 gantt-schedule-timeline-calendar是收费版本的,可以根据实际需要进行选用。

当前组件样子如下:

image.png

测试案例如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!DOCTYPE html>
<html charset="utf-8">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>GanttElastic editor demo</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/dayjs"></script>

    <script src="https://unpkg.com/gantt-elastic/dist/GanttElastic.umd.js"></script>
    <script src="https://unpkg.com/gantt-elastic-header/dist/Header.umd.js"></script>
  </head>

  <body>
    <div style="width:100%;height:100%">
      <div id="app" v-if="!destroy">
        <gantt-elastic :tasks="tasks" :options="options" :dynamic-style="dynamicStyle">
          <gantt-header slot="header"></gantt-header>
          <gantt-footer slot="footer"></gantt-footer>
        </gantt-elastic>
      </div>
    </div>

    <script>
      // 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,
          progress: 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,
          progress: 50,
          type: 'milestone',
          collapsed: true,
          style: {
            base: {
              fill: '#1EBC61',
              stroke: '#0EAC51',
            },
            /*'tree-row-bar': {
              fill: '#1EBC61',
              stroke: '#0EAC51'
            },
            'tree-row-bar-polygon': {
              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,
          progress: 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,
          progress: 50,
          type: 'task',
          dependentOn: [3],
        },
      ];

      let options = {
        maxRows: 100,
        maxHeight: 300,
        title: {
          label: 'Your project title as html (link or whatever...)',
          html: false,
        },
        row: {
          height: 24,
        },
        calendar: {
          hour: {
            display: false,
          },
        },
        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: 'pl', // name String
          weekdays: 'Poniedziałek_Wtorek_Środa_Czwartek_Piątek_Sobota_Niedziela'.split('_'), // weekdays Array
          weekdaysShort: 'Pon_Wto_Śro_Czw_Pią_Sob_Nie'.split('_'), // OPTIONAL, short weekdays Array, use first three letters if not provided
          weekdaysMin: 'Pn_Wt_Śr_Cz_Pt_So_Ni'.split('_'), // OPTIONAL, min weekdays Array, use first two letters if not provided
          months: 'Styczeń_Luty_Marzec_Kwiecień_Maj_Czerwiec_Lipiec_Sierpień_Wrzesień_Październik_Listopad_Grudzień'.split('_'), // months Array
          monthsShort: 'Sty_Lut_Mar_Kwi_Maj_Cze_Lip_Sie_Wrz_Paź_Lis_Gru'.split('_'), // OPTIONAL, short months Array, use first three letters if not provided
          ordinal: n => `${n}`, // ordinal Function (number) => return number + output
          relativeTime: { // relative time format strings, keep %s %d as the same
            future: 'za %s', // e.g. in 2 hours, %s been replaced with 2hours
            past: '%s temu',
            s: 'kilka sekund',
            m: 'minutę',
            mm: '%d minut',
            h: 'godzinę',
            hh: '%d godzin', // e.g. 2 hours, %d been replaced with 2
            d: 'dzień',
            dd: '%d dni',
            M: 'miesiąc',
            MM: '%d miesięcy',
            y: 'rok',
            yy: '%d lat'
          }
       }*/
      };

      // create instance
      const app = new Vue({
        components: {
          'gantt-header': Header,
          'gantt-elastic': GanttElastic,
          'gantt-footer': {
            template: `<span>this is a footer</span>`,
          },
        },
        data: {
          tasks: tasks.map((task) => Object.assign({}, task)),
          options,
          dynamicStyle: {
            'task-list-header-label': {
              'font-weight': 'bold',
            },
          },
          destroy: false,
        },
      });

      // gantt state which will be updated in realtime
      let ganttState, ganttInstance;

      // listen to 'gantt-elastic.ready' or 'gantt-elastic.mounted' event
      // to get the gantt state for real time modification
      app.$on('gantt-elastic-ready', (ganttElasticInstance) => {
        ganttInstance = ganttElasticInstance;

        ganttInstance.$on('tasks-changed', (tasks) => {
          app.tasks = tasks;
        });
        ganttInstance.$on('options-changed', (options) => {
          app.options = options;
        });
        ganttInstance.$on('dynamic-style-changed', (style) => {
          app.dynamicStyle = style;
        });

        ganttInstance.$on('chart-task-mouseenter', ({ data, event }) => {
          console.log('task mouse enter', { data, event });
        });
        ganttInstance.$on('updated', () => {
          //console.log('gantt view was updated');
        });
        ganttInstance.$on('destroyed', () => {
          //console.log('gantt was destroyed');
        });
        ganttInstance.$on('times-timeZoom-updated', () => {
          console.log('time zoom changed');
        });
        ganttInstance.$on('taskList-task-click', ({ event, data, column }) => {
          console.log('task list clicked! (task)', { data, column });
        });
      });

      // mount gantt to DOM
      app.$mount('#app');
    </script>
  </body>
</html>
本文声明:

本作品由 cn華少 采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022.02.02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
免费JS甘特图组件dhtmlxgantt
参考:https://docs.dhtmlx.com/gantt/desktop__install_with_bower.html
用户1637609
2021/05/19
18.2K0
免费JS甘特图组件dhtmlxgantt
(来啦,老弟)从零实现一个日历组件
日历组件主要是由一个文本输入框组成,点击文本输入框后会在文本框下方显示日历面板,日历面板包含三部分:头部区(主要显示当面日历面板对应的年月以及四个年月上下切换按钮)、内容区(显示星期、以及42天)、底部区(今天快捷按钮,点击可以直接跳转到今天),同时点击日历面板外部可以关闭日历面板。
公众号---人生代码
2019/11/05
2.7K0
10分钟用Python或MATLAB制作漂亮的甘特图(Gantt)
说到生产调度,就不得不提甘特图这东西,可以用它来直观看调度的情况,非常方便。比如下图中:
短短的路走走停停
2020/05/15
8.7K0
10分钟用Python或MATLAB制作漂亮的甘特图(Gantt)
前端技术前沿8
实现倒计时(天数、时、分、秒) parseInt() 函数可解析一个字符串,并返回一个整数。 <body onload="leftTimer()"> <h2>剩余时间:</h2> <div id="timer"></div> </body> <script language="javascript" type="text/javascript"> function leftTimer(year,month,day,hour,minute,second){ var leftTime =
达达前端
2019/07/03
5.9K0
前端技术前沿8
甘特图的这些新玩法,你都知道吗?
甘特图是项目管理、生产排程、节点管理中非常常见的一个功能。那么,有没有一种方法能够帮助将甘特图引入到系统中,让数据的进度、排程数据的展示更加直观,让管理更加高效。
葡萄城控件
2023/10/16
3460
甘特图的这些新玩法,你都知道吗?
记录前端开发过程中遇到的一个问题
博客新增菜单后,点击新菜单后其中的js不生效,刷新页面后才生效,这个页面是通过<a href="xxx" target=_self>标签跳转过来的。下面上我的代码
晓果冻
2022/09/08
3130
记录前端开发过程中遇到的一个问题
Bootstrap Metronic 学习记录(二)菜单栏
1.简介 1)  .环境配置 2)  .提取页面 2).动态生成菜单(无限级别树) 2.系统环境配置 项目需要程序数据支撑,这里选择MVC5.0+EF6.0[SQLSERVER](不对MVC架构和SQLServer做出解读) 运行环境:VS2013+MVC5.0+EF6.1+SQLServer2012 解决方案名称:AppSolution 项目名称:App.Web(UI层)与App.Models(数据访问层) -直接访问模式 提取theme下的所有文件到MVC的Content,提取admin的index.h
用户1149182
2018/01/16
5.5K0
Bootstrap Metronic 学习记录(二)菜单栏
markdown绘图插件----mermaid简介
当撰写文档的时候,对于流程图的生成大多使用Visio等繁重的工具,没有一种轻便的工具能够画图从而简化文档的编写,就像markdown那样。
流川疯
2019/01/18
4.8K1
添加恋爱计时小组件
前言 一个可以让你网站侧栏不在那么孤单的代码,自定义恋爱计时 实现效果 代码 <!-- 恋爱计时 --> <ul class="header_slideout-count"> <div id="lovesyl" style="width: 100%; height: 100%; text-align: center; font-size: 1rem;"> <div id="lovesylImage" style="width: 220px; margin: 0 auto;">
777nx
2023/05/02
3750
添加恋爱计时小组件
「后端小伙伴来学前端了」Vue中Props 实现组件通信TodoList案例
上篇文章写了个V利用Props进行组件之间的通信,这不立马就安排上这个案例拉丫。光学不敲等于没学哈(资深大佬除外哈)
宁在春
2022/10/31
4860
「后端小伙伴来学前端了」Vue中Props 实现组件通信TodoList案例
使用ABP打造SAAS系统(2)——前端框架选择[通俗易懂]
  作者用过的前端框架不少,曾经还在一个项目中同时使用两套框架控件(年少无知、效率特慢),所以可供选择的前端框架有不少:
全栈程序员站长
2022/11/04
2.7K0
使用ABP打造SAAS系统(2)——前端框架选择[通俗易懂]
Django的主体页面抽取(七)
在潦草的完成了注册与登录之后,下面开始编写平台的主体部分了。 忘记密码和恢复密码部分在最后完善的时候补上。
zx钟
2019/07/19
9060
跨年快乐动态炫酷烟花网页代码
烟花效果的实现可以采用前端技术,如HTML、CSS和JavaScript。通过结合动画、粒子效果等技术手段,可以创建出独特而炫目的烟花效果。同时,考虑到性能和兼容性,需要确保效果在各种设备上都能够良好运行。
博客趣
2024/05/05
4720
Typecho添加恋爱计时小组件-星泽V社
1.一个可以让你网站侧栏不在那么孤单的代码.可以加入你那 可爱 ,漂亮的女朋友表情还有 屌丝 的你 2.支持修改代码中的qq号即可更改头像图片,自定义恋爱计时 3.孤零零的我也只能静静的把好东西分享跟你们了!
星泽V社
2022/03/30
6220
Typecho添加恋爱计时小组件-星泽V社
教育平台项目前端:Vue.js 高级
Vue cli 是基于 Vue 的应用开发提供的一个标准的脚手架工具,为应用搭建基础的框架结构,提供插件、开发服务、Preset、构建打包功能。
RendaZhang
2020/09/08
3.3K0
大型项目技术栈第一讲 Vue.js的使用
Vue.js是一个构建数据驱动的 web 界面的渐进式框架。Vue.js 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件。它不仅易于上手,还便于与第三方库或既有项目整合。
易兮科技
2020/09/27
5.3K0
大型项目技术栈第一讲  Vue.js的使用
Vue 弹幕功能实现步骤与组件封装详细指南
通过以上使用方法和组件封装,您可以在Vue项目中实现一个功能完整、性能优良的弹幕系统,支持视频、直播等多种场景,并且可以根据需求进行灵活扩展和定制。
小焱
2025/06/01
1730
Vue 弹幕功能实现步骤与组件封装详细指南
学习 Vue 3 全家桶 - 打造自己的通用组件库 - 环境搭建
参考 Element3 布局容器页面,共有 container、header、footer、aside、main 五个组件,这个组合可以很方便地实现常见的页面布局:
Cellinlab
2023/05/17
3360
关于Python可视化Dash工具-dash核心组件和html组件
关于Python可视化Dash工具,不能不提dash核心组件和html组件,用户可以使用Python结构和dash-html-components库来构建布局,而不是编写HTML或使用HTML模板引擎 。dash-html-components库和标准的html还是有点区别的。以下内容来自dash官网的介绍:
python与大数据分析
2022/03/11
1.7K0
关于Python可视化Dash工具-dash核心组件和html组件
提升Typecho首页ttfb加载速度以及若干升级
查看主题的index.php找header,顺势找到header.php文件,你会在<header></header>看到如下代码: <link rel="icon" type="image/ico" href="/favicon.ico"> 因此我们在typecho包的根目录下放入favicon.ico图片
西柚dzh
2022/06/09
9180
提升Typecho首页ttfb加载速度以及若干升级
推荐阅读
相关推荐
免费JS甘特图组件dhtmlxgantt
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档