国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

vue3 甘特圖(二):甘特圖時間軸切換

這篇具有很好參考價值的文章主要介紹了vue3 甘特圖(二):甘特圖時間軸切換。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

vue3 甘特圖(二):gantt時間軸切換

  1.固定時間軸縮放級別  

    gantt.config.scale_unit = "month"; //時間軸單位
    gantt.config.step = 1;//單位數(shù)
    gantt.config.date_scale = "%Y年%M";//時間軸展現(xiàn)方式

  2.動態(tài)改變時間軸縮放

    點擊不同按鈕,切換時間軸狀態(tài)  vue3 甘特圖(二):甘特圖時間軸切換
  2.1 配置時間軸參數(shù)

    levels里可配置多個級別。

   scales展示時間軸對應(yīng)多少行,下的format可自定展現(xiàn)方式,css屬性方法可判斷是否為軸,給周末添加上高亮屬性。

?

?

const zoomConfig = {
  levels: [
    {
      name: 'day',
      scale_height: 60,
      scales: [{ unit: 'day', step: 1, format: '%d %M' }]
    },
    {
      name: 'week',
      scale_height: 60,
      scales: [
        {
          unit: 'week',
          step: 1,
          format: function (date) {
            let dateToStr = gantt.date.date_to_str('%m-%d')
            let endDate = gantt.date.add(date, -6, 'day')
            let weekNum = gantt.date.date_to_str('%W')(date) //第幾周
            return dateToStr(endDate) + ' 至 ' + dateToStr(date)
          }
        },
        {
          unit: 'day',
          step: 1,
          format: '%d', // + "周%D"
          css: function (date) {
            if (date.getDay() == 0 || date.getDay() == 6) {
              return 'day-item weekend weekend-border-bottom'
            } else {
              return 'day-item'
            }
          }
        }
      ]
    },
    {
      name: 'month',
      scale_height: 60,
      min_column_width: 18,
      scales: [
        { unit: 'month', format: '%Y-%m' },
        {
          unit: 'day',
          step: 1,
          format: '%d',
          css: function (date) {
            if (date.getDay() == 0 || date.getDay() == 6) {
              return 'day-item weekend weekend-border-bottom'
            } else {
              return 'day-item'
            }
          }
        }
      ]
    },
    {
      name: 'quarter',
      height: 60,
      min_column_width: 110,
      scales: [
        {
          unit: 'quarter',
          step: 1,
          format: function (date) {
            let yearStr = new Date(date).getFullYear() + '年'
            let dateToStr = gantt.date.date_to_str('%M')
            let endDate = gantt.date.add(gantt.date.add(date, 3, 'month'), -1, 'day')
            return yearStr + dateToStr(date) + ' - ' + dateToStr(endDate)
          }
        },
        {
          unit: 'week',
          step: 1,
          format: function (date) {
            let dateToStr = gantt.date.date_to_str('%m-%d')
            let endDate = gantt.date.add(date, 6, 'day')
            let weekNum = gantt.date.date_to_str('%W')(date)
            return dateToStr(date) + ' 至 ' + dateToStr(endDate)
          }
        }
      ]
    },
    {
      name: 'year',
      scale_height: 50,
      min_column_width: 150,
      scales: [
        { unit: 'year', step: 1, format: '%Y年' },
        { unit: 'month', format: '%Y-%m' }
      ]
    }
  ]
}
  2.2 初始化時間軸配置
  gantt.ext.zoom.init(zoomConfig) //配置初始化擴展
  gantt.ext.zoom.setLevel('month') //切換到指定的縮放級別
  2.3 改變時間軸
const changeTime = () => {
  gantt.ext.zoom.setLevel(data.timeState)
} 
  2.4 周末或特殊日期高亮
.weekend {
      background: #ff9e2f;
      color: #fff;
    }

  3. 完整示例代碼

<template>
  <section class="my-gantt">
    <div class="time-box">
      <el-radio-group v-model="data.timeState" @change="changeTime">
        <el-radio-button
          v-for="(time, t_index) in data.timeList"
          :key="t_index"
          :label="time.code"
          size="default"
          border
          >{{ time.name }}</el-radio-button
        >
      </el-radio-group>
    </div>
    <div id="gantt_here" class="gantt-container"></div>
  </section>
</template>

<script setup>
import { reactive, toRefs, onBeforeMount, onMounted, watchEffect, defineExpose } from 'vue'

import { gantt } from 'dhtmlx-gantt'
import 'dhtmlx-gantt/codebase/dhtmlxgantt.css'
import demoData from './ganttData.json'

const data = reactive({
  timeList: [
    // {
    //     name: "周",
    //     code: "week",
    // },
    {
      name: '月',
      code: 'month'
    },
    {
      name: '季',
      code: 'quarter'
    },
    {
      name: '年',
      code: 'year'
    }
  ],
  timeState: 'month'
})

const zoomConfig = {
  levels: [
    {
      name: 'day',
      scale_height: 60,
      scales: [{ unit: 'day', step: 1, format: '%d %M' }]
    },
    {
      name: 'week',
      scale_height: 60,
      scales: [
        {
          unit: 'week',
          step: 1,
          format: function (date) {
            let dateToStr = gantt.date.date_to_str('%m-%d')
            let endDate = gantt.date.add(date, -6, 'day')
            let weekNum = gantt.date.date_to_str('%W')(date) //第幾周
            return dateToStr(endDate) + ' 至 ' + dateToStr(date)
          }
        },
        {
          unit: 'day',
          step: 1,
          format: '%d', // + "周%D"
          css: function (date) {
            if (date.getDay() == 0 || date.getDay() == 6) {
              return 'day-item weekend weekend-border-bottom'
            } else {
              return 'day-item'
            }
          }
        }
      ]
    },
    {
      name: 'month',
      scale_height: 60,
      min_column_width: 18,
      scales: [
        { unit: 'month', format: '%Y-%m' },
        {
          unit: 'day',
          step: 1,
          format: '%d',
          css: function (date) {
            if (date.getDay() == 0 || date.getDay() == 6) {
              return 'day-item weekend weekend-border-bottom'
            } else {
              return 'day-item'
            }
          }
        }
      ]
    },
    {
      name: 'quarter',
      height: 60,
      min_column_width: 110,
      scales: [
        {
          unit: 'quarter',
          step: 1,
          format: function (date) {
            let yearStr = new Date(date).getFullYear() + '年'
            let dateToStr = gantt.date.date_to_str('%M')
            let endDate = gantt.date.add(gantt.date.add(date, 3, 'month'), -1, 'day')
            return yearStr + dateToStr(date) + ' - ' + dateToStr(endDate)
          }
        },
        {
          unit: 'week',
          step: 1,
          format: function (date) {
            let dateToStr = gantt.date.date_to_str('%m-%d')
            let endDate = gantt.date.add(date, 6, 'day')
            let weekNum = gantt.date.date_to_str('%W')(date)
            return dateToStr(date) + ' 至 ' + dateToStr(endDate)
          }
        }
      ]
    },
    {
      name: 'year',
      scale_height: 50,
      min_column_width: 150,
      scales: [
        { unit: 'year', step: 1, format: '%Y年' },
        { unit: 'month', format: '%Y-%m' }
      ]
    }
  ]
}

//初始化甘特圖
const initGantt = () => {
  gantt.config.grid_width = 350
  gantt.config.add_column = false //添加符號

  //時間軸圖表中,如果不設(shè)置,只有行邊框,區(qū)分上下的任務(wù),設(shè)置之后帶有列的邊框,整個時間軸變成格子狀。
  gantt.config.autofit = false
  gantt.config.row_height = 60
  gantt.config.bar_height = 34
  // gantt.config.fit_tasks = true //自動延長時間刻度,以適應(yīng)所有顯示的任務(wù)
  gantt.config.auto_types = true //將包含子任務(wù)的任務(wù)轉(zhuǎn)換為項目,將沒有子任務(wù)的項目轉(zhuǎn)換回任務(wù)
  // gantt.config.xml_date = '%Y-%m-%d' //甘特圖時間數(shù)據(jù)格式
  gantt.config.readonly = true //是否只讀
  gantt.i18n.setLocale('cn') //設(shè)置語言
  gantt.init('gantt_here') //初始化
  gantt.parse(demoData) //填充數(shù)據(jù)

  gantt.ext.zoom.init(zoomConfig) //配置初始化擴展
  gantt.ext.zoom.setLevel('month') //切換到指定的縮放級別
}

const changeTime = () => {
  gantt.ext.zoom.setLevel(data.timeState)
}

onBeforeMount(() => {})
onMounted(() => {
  initGantt()
})
watchEffect(() => {})
defineExpose({
  ...toRefs(data)
})
</script>
<style scoped lang="scss">
.my-gantt {
  height: 800px;
  width: 100vw;
  .time-box {
    text-align: center;
    margin-bottom: 20px;
  }
  ::v-deep .gantt-container {
    width: 100%;
    height: 100%;
    .weekend {
      background: #ff9e2f;
      color: #fff;
    }
  }
}
</style>

  4. 示例數(shù)據(jù)

    見:vue3 甘特圖(一):選擇與初始化甘特圖 - 根號九九 - 博客園 (cnblogs.com)文章來源地址http://www.zghlxwxcb.cn/news/detail-695043.html

到了這里,關(guān)于vue3 甘特圖(二):甘特圖時間軸切換的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • DHTMLX Gantt 8.0.5 Crack -甘特圖

    DHTMLX Gantt 8.0.5 Crack -甘特圖

    2023 年 9 月 1 日。錯誤修復(fù)版本 修復(fù) 修復(fù)通過gantt.getGanttInstance配置啟用擴展而觸發(fā)的錯誤警告 修復(fù)啟用skip_off_time配置時gantt.exportToExcel()的不正確工作 示例查看器的改進 2023 年 7 月 31 日。錯誤修復(fù)版本 修復(fù) 修復(fù)數(shù)據(jù)處理器不跟蹤資源數(shù)據(jù)存儲更改的問題 解決禁用process_r

    2024年02月09日
    瀏覽(25)
  • MATLAB | 如何使用MATLAB繪制甘特圖(gantt chart)

    MATLAB | 如何使用MATLAB繪制甘特圖(gantt chart)

    好久不見哈,今天帶來一個不咋炫酷但是比較實用的甘特圖繪制,就畫一堆矩形嘛非常簡單。 之所以這期工具函數(shù)放在最前面是因為比較短哈: 基本使用 設(shè)置任務(wù)開始時間,結(jié)束時間及任務(wù)編號后,調(diào)用工具函數(shù)繪圖即可: 不咋好看的圓角 設(shè)置 Curvature 為0-1之間的數(shù)值即可

    2024年02月09日
    瀏覽(98)
  • 甘特圖控件DHTMLX Gantt教程:dhtmlxGantt 與PHP: Laravel(下)

    DHTMLX Gantt是用于跨瀏覽器和跨平臺應(yīng)用程序的功能齊全的Gantt圖表。可滿足項目管理應(yīng)用程序的大部分開發(fā)需求,具備完善的甘特圖圖表庫,功能強大,價格便宜,提供豐富而靈活的JavaScript API接口,與各種服務(wù)器端技術(shù)(PHP,ASP.NET,Java等)簡單集成,滿足多種定制開發(fā)需求

    2024年02月06日
    瀏覽(51)
  • 甘特圖組件DHTMLX Gantt用例 - 如何自定義任務(wù)、月標(biāo)記和網(wǎng)格新外觀

    甘特圖組件DHTMLX Gantt用例 - 如何自定義任務(wù)、月標(biāo)記和網(wǎng)格新外觀

    dhtmlxGantt是用于跨瀏覽器和跨平臺應(yīng)用程序的功能齊全的Gantt圖表??蓾M足項目管理應(yīng)用程序的所有需求,是最完善的甘特圖圖表庫。 本文將為大家揭示DHTMLX Gantt自定義的典型用例,包括自定義任務(wù)、網(wǎng)格的新外觀等,來展示其功能的強大性! DHTMLX Gantt正式版下載 用例 - 新建

    2024年02月08日
    瀏覽(27)
  • vue3 手寫甘特圖

    (gantt-chart/index.vue)

    2024年02月12日
    瀏覽(8)
  • 甘特圖組件DHTMLX Gantt用例 - 如何拆分任務(wù)和里程碑項目路線圖

    甘特圖組件DHTMLX Gantt用例 - 如何拆分任務(wù)和里程碑項目路線圖

    創(chuàng)建一致且引人注意的視覺樣式是任何項目管理應(yīng)用程序的重要要求,這就是為什么我們會在這個系列中繼續(xù)探索DHTMLX Gantt圖庫的自定義。在本文中我們將考慮一個新的甘特圖定制場景,DHTMLX Gantt組件如何創(chuàng)建一個項目路線圖。 DHTMLX Gantt正式版下載 用例 - 帶有自定義時間尺

    2024年02月05日
    瀏覽(32)
  • 甘特圖工具DHTMLX Gantt 8.0搶先看, 改進的資源管理、更新的自動計劃等功能,一起查閱吧

    甘特圖工具DHTMLX Gantt 8.0搶先看, 改進的資源管理、更新的自動計劃等功能,一起查閱吧

    DHTMLX Gantt是用于跨瀏覽器和跨平臺應(yīng)用程序的功能齊全的Gantt圖表??蓾M足項目管理應(yīng)用程序的大部分開發(fā)需求,具備完善的甘特圖圖表庫,功能強大,價格便宜,提供豐富而靈活的JavaScript API接口,與各種服務(wù)器端技術(shù)(PHP,ASP.NET,Java等)簡單集成,滿足多種定制開發(fā)需求

    2023年04月08日
    瀏覽(30)
  • vue3切換路由模式——Hash 、histoary

    1、history模式 使用createWebHistory 2、hash模式 使用createWebHashHistory 綜上所述: history 對應(yīng) createWebHistory hash 對應(yīng) createWebHashHistory

    2024年02月02日
    瀏覽(19)
  • Vue3 Radio單選切換展示不同內(nèi)容

    Vue3 Radio單選切換展示不同內(nèi)容

    環(huán)境:vue3+ts+vite+element plus 技巧:v-if,v-show的使用 實現(xiàn)功能:點擊單選框展示不同的輸入框 效果實現(xiàn)前的代碼: 1.默認選項型號是選中的,型號輸入框也是展示的,那么顏色輸入框是需要隱藏, 定義isShow, 此時,isShow是true,! isShow就是false了,顯示如下 2.獲取單選框選擇的

    2024年02月15日
    瀏覽(22)
  • Taro+vue3 實現(xiàn)滑動列表 時切換電影

    Taro+vue3 實現(xiàn)滑動列表 時切換電影

    以上代碼是滑動的組件?

    2024年01月16日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包