網站首頁 編程語言 正文
示例圖:
官方文檔參考:highcharts gantt
甘特圖示例
使用示例:
<template>
<div id="container"></div>
</template>
<script>
export default {
mounted() {
let month = "2022-12";
const moment = this.$moment;
const WEEKS = {
0: "日",
1: "一",
2: "二",
3: "三",
4: "四",
5: "五",
6: "六",
};
const data = [
{
name: "1#機1",
start: new Date("2022-12-01 09:00:00").getTime(),
end: new Date("2022-12-11 09:00:00").getTime(),
completed: 0.25,
y: 0,
},
{
name: "1#機1",
start: new Date("2022-12-13 09:00:00").getTime(),
end: new Date("2022-12-18 09:00:00").getTime(),
y: 0,
},
{
name: "2#機2",
start: new Date("2022-12-08 09:00:00").getTime(),
end: new Date("2022-12-10 19:20:40").getTime(),
y: 1,
},
{
name: "3#機3",
start: new Date("2022-12-06 09:00:00").getTime(),
end: new Date("2022-12-21 09:00:00").getTime(),
completed: {
amount: 0.12,
fill: "red",
},
y: 2,
},
{
name: "4#機4",
start: new Date("2022-12-21 09:00:00").getTime(),
end: new Date("2022-12-31 09:00:00").getTime(),
y: 3,
},
];
// 自定義主題
const my_skin = {
//顏色數組,默認從數組第一個元素取色
// colors: [
// "#33FF33",
// "#f45b5b",
// "#7798BF",
// "#aaeeee",
// "#ff0066",
// "#eeaaee",
// "#55BF3B",
// "#DF5353",
// "#7798BF",
// "#aaeeee",
// ],
//背景
chart: {
backgroundColor: "#364766",
},
xAxis: {
labels: {
style: {
color: "#f5f7fa",
},
},
},
yAxis: {
title: {
style: { color: "#f5f7fa" },
},
markable: { enabled: false }, //不顯示每一個點的實心
labels: {
style: {
color: "#f5f7fa",
},
},
},
global: {
useUTC: false, // 不使用utc時間
},
lang: {
noData: "暫無數據",
},
};
// 全局配置,需要在圖標初始化之前配置
this.$highcharts.setOptions(my_skin, {
global: {
useUTC: false, // 不使用utc時間
},
lang: {
noData: "暫無數據",
},
});
let max = moment(this.queryForm.plan_date2).add(1, "days");
this.$highcharts.ganttChart("container", {
xAxis: [
{
min: moment(month).valueOf(),
// max: moment(max).valueOf(), // 根據時間區間選擇
max: moment(month).endOf("month").valueOf(), // 根據每個月選擇
gridLineEidth: 1,
minTickInterval: 1000 * 60 * 60 * 24,
currentDateIndicator: true,
tickPixelInterval: 70,
grid: {
borderWidth: 1, // 右側表頭邊框寬度
cellHeight: 35, // 右側日期表頭高度
},
labels: {
align: "center",
formatter: function () {
return `周${WEEKS[moment(this.value).day()]}`;
},
},
},
{
gridLineWidth: 1,
minTickInterval: 1000 * 60 * 60 * 24,
tickPixelInterval: 100,
grid: {
borderWidth: 1, // 右側表頭邊框寬度
cellHeight: 30, // 右側日期表頭高度
},
labels: {
align: "center",
formatter: function () {
return `${moment(this.value).format("M-D")} `;
},
},
},
],
yAxis: {
type: "category",
grid: {
enabled: true,
borderColor: "#e6e6e6",
borderWidth: 1,
columns: [
{
title: {
text: "設備",
},
labels: {
format: "{point.name}",
},
},
],
},
},
tooltip: {
formatter: function () {
return `<div>
設備:${this.point.name}
<br />
開始時間:${moment(this.point.start).format("YYYY-MM-DD HH:mm:ss")}
<br />
結束時間:${moment(this.point.end).format("YYYY-MM-DD HH:mm:ss")}
</div>`;
},
},
series: [
{
data,
},
],
plotOptions: {
series: {
animation: false, // Do not animate dependency connectors
dragDrop: {
draggableX: false, // 橫向拖拽
draggableY: false, // 縱向拖拽
dragMinY: 0, // 縱向拖拽下限
dragMaxY: 3, // 縱向拖拽上限
dragPrecisionX: 3600000, // 橫向拖拽精度,單位毫秒
},
dataLabels: {
enabled: true,
format: "{point.name}",
style: {
cursor: "default",
pointerEvents: "none",
color: "#ffffff",
},
},
allowPointSelect: true,
},
},
exporting: {
sourceWidth: 1000,
},
credits: {
// 去掉右下角版權信息
enabled: false,
},
chart: {
spacingLeft: 10,
spacingTop: 10,
},
pane: {
background: [
{
backgroundColor: "red",
},
],
},
});
},
};
</script>
原文鏈接:https://blog.csdn.net/qq_38157825/article/details/128612488
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2023-11-15 Latex文獻報錯 Something‘s wrong--perhaps a missing \it
- 2022-11-03 C#中委托、事件和回調的使用及說明_C#教程
- 2022-06-02 jquery實現淘寶商品圖片局部放大_jquery
- 2024-04-04 netty使用http和webSocket
- 2022-06-19 C#文件非占用讀取與幫助類FileHelper_C#教程
- 2022-03-26 C語言輸出孿生素數的實現示例_C 語言
- 2022-01-26 阿里云服務器端口請求失敗(在控制臺把端口添加到服務器的安全組)
- 2022-07-02 less,sass,scss的關系與區別
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支