Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tinyu5
vue2-tools
提交
7d040942
V
vue2-tools
项目概览
Tinyu5
/
vue2-tools
与 Fork 源项目一致
Fork自
inscode / VueJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue2-tools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7d040942
编写于
3月 28, 2024
作者:
T
tinyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:调整配置
上级
23b43487
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
255 addition
and
188 deletion
+255
-188
src/components/ganttchart/useGantt.js
src/components/ganttchart/useGantt.js
+255
-188
未找到文件。
src/components/ganttchart/useGantt.js
浏览文件 @
7d040942
import
*
as
echarts
from
'
echarts
'
;
import
moment
from
'
moment
'
;
export
default
function
(){
const
baseOption
=
{
backgroundColor
:
'
transparent
'
,
color
:
[
'
#fc7778
'
,
'
#7481fd
'
,
'
#02d18f
'
,
'
#2cd0ff
'
,
'
#edcf02
'
,
'
#fe8a3d
'
],
grid
:
{
containLabel
:
true
,
show
:
false
,
right
:
0
,
left
:
0
,
bottom
:
0
,
top
:
0
,
borderColor
:
'
#79B5CA
'
,
borderWidth
:
1
const
GraphType
=
Object
.
freeze
({
Rect
:
1
,
Img
:
2
,
})
/**
* 获取自定义渲染函数
* 内部设定高度映射 y[1-3] 2:表示竖向中间位置
*/
function
getRenderItem
(
yTick
)
{
return
function
(
params
,
api
)
{
const
data
=
{
start
:
api
.
value
(
0
),
end
:
api
.
value
(
1
)
}
const
status
=
api
.
value
(
2
)
const
[
start
,
pos_y
]
=
api
.
coord
([
data
.
start
,
yTick
])
const
[
end
]
=
api
.
coord
([
data
.
end
,
yTick
])
const
height
=
api
.
size
([
0
,
1
])[
1
]
*
0.15
const
rect
=
echarts
.
graphic
.
clipRectByRect
(
{
x
:
start
,
y
:
pos_y
-
height
/
2
,
width
:
end
-
start
,
height
:
height
},
{
x
:
params
.
coordSys
.
x
,
y
:
params
.
coordSys
.
y
,
width
:
params
.
coordSys
.
width
,
height
:
params
.
coordSys
.
height
}
)
const
childrenImageLine
=
[
{
type
:
'
rect
'
,
shape
:
rect
,
style
:
api
.
style
(),
emphasis
:
{
style
:
api
.
styleEmphasis
()
}
}
]
return
{
type
:
'
group
'
,
children
:
childrenImageLine
}
}
}
export
default
function
()
{
const
baseOption
=
{
backgroundColor
:
'
transparent
'
,
color
:
[
'
#fc7778
'
,
'
#7481fd
'
,
'
#02d18f
'
,
'
#2cd0ff
'
,
'
#edcf02
'
,
'
#fe8a3d
'
],
grid
:
{
containLabel
:
true
,
show
:
false
,
right
:
0
,
left
:
0
,
bottom
:
0
,
top
:
0
,
borderColor
:
'
#79B5CA
'
,
borderWidth
:
1
},
dataZoom
:
{
show
:
true
,
start
:
0
,
end
:
25
,
// 显示25%
zoomOnMouseWheel
:
true
,
rangeMode
:
[
'
percent
'
,
'
percent
'
],
type
:
'
inside
'
,
filterMode
:
'
none
'
},
xAxis
:
{
type
:
'
time
'
,
// min: '2020-02-28 12:00:00',
// max: '2020-05-28 12:00:00',
// 主刻度尺
axisTick
:
{
show
:
true
,
interval
:
0
,
length
:
10
,
inside
:
true
,
lineStyle
:
{
color
:
'
#bbb
'
,
width
:
2
},
dataZoom
:
{
show
:
true
,
start
:
0
,
end
:
25
,
// 显示25%
zoomOnMouseWheel
:
true
,
rangeMode
:
[
'
percent
'
,
'
percent
'
],
type
:
'
inside
'
,
filterMode
:
'
none
'
animation
:
true
,
animationEasingUpdate
:
'
linear
'
,
animationDurationUpdate
:
100
,
animationDelayUpdate
:
300
},
splitLine
:
{
show
:
false
},
// 次刻度尺
minorTick
:
{
show
:
true
,
length
:
5
,
lineStyle
:
{
color
:
'
#bbb
'
,
width
:
1
}
},
axisLabel
:
{
inside
:
true
,
hideOverlap
:
false
,
show
:
true
,
interval
:
0
,
formatter
:
'
{yyyy}-{MM}-{dd} {HH}:{mm}
'
,
// '{yyyy}-{MM}-{dd}\n{hh}:{mm}:{ss}',
textStyle
:
{
// 图例文字的样式
color
:
'
#333
'
,
fontSize
:
10
}
},
axisLine
:
{
show
:
true
,
// 这里的show用于设置是否显示x轴那一条线 默认为true
lineStyle
:
{
// lineStyle里面写x轴那一条线的样式
color
:
'
#bbb
'
,
width
:
2
// 轴线的粗细
// shadowColor: 'white',
// shadowBlur: 10,
// opacity: 1,
// shadowOffsetY: -1,
}
}
},
yAxis
:
{
show
:
false
,
type
:
'
value
'
,
min
:
1
,
max
:
3
,
axisLabel
:
{
show
:
false
}
},
tooltip
:
{
trigger
:
'
item
'
,
backgroundColor
:
'
#333333
'
,
borderWidth
:
1
,
borderColor
:
'
#555
'
,
padding
:
4
,
position
:
'
top
'
,
// 设置tooltip显示位置
// point: 鼠标位置,如 [20, 40]。
// params: 同 formatter 的参数相同。
// dom: tooltip 的 dom 对象。
// rect: 只有鼠标在图形上时有效,是一个用x, y, width, height四个属性表达的图形包围盒。
// size: 包括 dom 的尺寸和 echarts 容器的当前尺寸,例如:{contentSize: [width, height], viewSize: [width, height]}。
// position(point, params, dom, rect, size) {
// return [point[0], point[1] - 80];
// },
textStyle
:
{
// textStyle里面写x轴下的字体的样式
color
:
'
#fff
'
,
fontSize
:
12
},
formatter
:
val
=>
{
return
`
${
typeof
val
.
value
[
2
]
===
'
string
'
?
val
.
value
[
2
]
:
val
.
seriesName
}
${
moment
(
val
.
value
[
0
]).
format
(
'
MM-DD HH:mm
'
)}
~
${
moment
(
val
.
value
[
1
]
).
format
(
'
MM-DD HH:mm
'
)}
`
// let str = `<div style = "background:url( ${require('./images/trangle-border.png')}) no-repeat center center ;width:177px;height:65px;padding: 5px 0 0 5px;">状态:${
// val.seriesName
// }<br/>时间:${val.value}</div>`;
// return str;
}
// alwaysShowContent: true,
},
series
:
[
{
name
:
'
测试1
'
,
type
:
'
custom
'
,
colorBy
:
'
data
'
,
encode
:
{
x
:
[
0
,
1
],
y
:
1
},
xAxis
:
{
type
:
'
time
'
,
// min: '2020-02-28 12:00:00',
// max: '2020-05-28 12:00:00',
// 主刻度尺
axisTick
:
{
show
:
true
,
interval
:
0
,
length
:
10
,
inside
:
true
,
lineStyle
:
{
color
:
'
#bbb
'
,
width
:
2
},
animation
:
true
,
animationEasingUpdate
:
'
linear
'
,
animationDurationUpdate
:
100
,
animationDelayUpdate
:
300
},
splitLine
:
{
show
:
false
},
// 次刻度尺
minorTick
:
{
show
:
true
,
length
:
5
,
lineStyle
:
{
color
:
'
#bbb
'
,
width
:
1
}
},
axisLabel
:
{
inside
:
true
,
hideOverlap
:
false
,
show
:
true
,
interval
:
0
,
formatter
:
'
{yyyy}-{MM}-{dd} {HH}:{mm}
'
,
// '{yyyy}-{MM}-{dd}\n{hh}:{mm}:{ss}',
textStyle
:
{
// 图例文字的样式
color
:
'
#333
'
,
fontSize
:
10
}
},
axisLine
:
{
show
:
true
,
// 这里的show用于设置是否显示x轴那一条线 默认为true
lineStyle
:
{
// lineStyle里面写x轴那一条线的样式
color
:
'
#bbb
'
,
width
:
2
// 轴线的粗细
// shadowColor: 'white',
// shadowBlur: 10,
// opacity: 1,
// shadowOffsetY: -1,
}
itemStyle
:
{
emphasis
:
{
borderColor
:
'
rgba(192, 249, 254, 0.85)
'
,
borderType
:
'
solid
'
,
borderWidth
:
1
,
shadowColor
:
'
rgba(192, 249, 254, 0.85)
'
,
shadowOffsetY
:
1
,
shadowOffsetX
:
-
1
,
shadowBlur
:
5
}
},
yAxis
:
{
show
:
false
,
type
:
'
value
'
,
min
:
1
,
max
:
3
,
axisLabel
:
{
show
:
false
}
renderItem
:
getRenderItem
(
2
),
data
:
[
{
value
:
[
'
2020-03-01 12:00:00
'
,
'
2020-03-03 00:00:00
'
]
},
[
'
2020-03-03 01:00:00
'
,
'
2020-03-14 00:00:00
'
],
[
'
2020-03-14 08:03:00
'
,
'
2020-03-14 08:13:00
'
],
[
'
2020-03-15 02:00:00
'
,
'
2020-04-01 00:00:00
'
]
]
},
{
name
:
'
测试2
'
,
type
:
'
custom
'
,
colorBy
:
'
data
'
,
encode
:
{
x
:
[
0
,
1
],
y
:
1
},
tooltip
:
{
trigger
:
'
item
'
,
backgroundColor
:
'
#333333
'
,
borderWidth
:
1
,
borderColor
:
'
#555
'
,
padding
:
4
,
position
:
'
top
'
,
// 设置tooltip显示位置
// point: 鼠标位置,如 [20, 40]。
// params: 同 formatter 的参数相同。
// dom: tooltip 的 dom 对象。
// rect: 只有鼠标在图形上时有效,是一个用x, y, width, height四个属性表达的图形包围盒。
// size: 包括 dom 的尺寸和 echarts 容器的当前尺寸,例如:{contentSize: [width, height], viewSize: [width, height]}。
// position(point, params, dom, rect, size) {
// return [point[0], point[1] - 80];
// },
textStyle
:
{
// textStyle里面写x轴下的字体的样式
color
:
'
#fff
'
,
fontSize
:
12
itemStyle
:
{
emphasis
:
{
borderColor
:
'
rgba(192, 249, 254, 0.85)
'
,
borderType
:
'
solid
'
,
borderWidth
:
1
,
shadowColor
:
'
rgba(192, 249, 254, 0.85)
'
,
shadowOffsetY
:
1
,
shadowOffsetX
:
-
1
,
shadowBlur
:
5
}
},
renderItem
:
getRenderItem
(
1.75
),
data
:
[
{
value
:
[
'
2020-02-29 12:00:00
'
,
'
2020-03-02 00:00:00
'
]
},
formatter
:
val
=>
{
return
`
${
typeof
val
.
value
[
2
]
===
'
string
'
?
val
.
value
[
2
]
:
val
.
seriesName
}
${
moment
(
val
.
value
[
0
]).
format
(
'
MM-DD HH:mm
'
)}
~
${
moment
(
val
.
value
[
1
]
).
format
(
'
MM-DD HH:mm
'
)}
`
// let str = `<div style = "background:url( ${require('./images/trangle-border.png')}) no-repeat center center ;width:177px;height:65px;padding: 5px 0 0 5px;">状态:${
// val.seriesName
// }<br/>时间:${val.value}</div>`;
// return str;
]
},
{
name
:
'
测试3
'
,
type
:
'
custom
'
,
colorBy
:
'
data
'
,
encode
:
{
x
:
[
0
,
1
],
y
:
1
},
itemStyle
:
{
emphasis
:
{
borderColor
:
'
rgba(192, 249, 254, 0.85)
'
,
borderType
:
'
solid
'
,
borderWidth
:
1
,
shadowColor
:
'
rgba(192, 249, 254, 0.85)
'
,
shadowOffsetY
:
1
,
shadowOffsetX
:
-
1
,
shadowBlur
:
5
}
// alwaysShowContent: true,
},
series
:
[
{
name
:
'
测试1
'
,
type
:
'
custom
'
,
colorBy
:
'
data
'
,
encode
:
{
x
:
[
0
,
1
],
y
:
1
},
itemStyle
:
{
emphasis
:
{
borderColor
:
'
rgba(192, 249, 254, 0.85)
'
,
borderType
:
'
solid
'
,
borderWidth
:
1
,
shadowColor
:
'
rgba(192, 249, 254, 0.85)
'
,
shadowOffsetY
:
1
,
shadowOffsetX
:
-
1
,
shadowBlur
:
5
}
},
renderItem
:
(
params
,
api
)
=>
{
const
data
=
{
start
:
api
.
value
(
0
),
end
:
api
.
value
(
1
)
}
const
status
=
api
.
value
(
2
)
const
[
start
,
pos_y
]
=
api
.
coord
([
data
.
start
,
2
])
const
[
end
]
=
api
.
coord
([
data
.
end
,
2
])
const
height
=
api
.
size
([
0
,
1
])[
1
]
*
0.15
const
rect
=
echarts
.
graphic
.
clipRectByRect
(
{
x
:
start
,
y
:
pos_y
-
height
/
2
,
width
:
end
-
start
,
height
:
height
},
{
x
:
params
.
coordSys
.
x
,
y
:
params
.
coordSys
.
y
,
width
:
params
.
coordSys
.
width
,
height
:
params
.
coordSys
.
height
}
)
const
childrenImageLine
=
[
{
type
:
'
rect
'
,
shape
:
rect
,
style
:
api
.
style
(),
emphasis
:
{
style
:
api
.
styleEmphasis
()
}
}
]
return
{
type
:
'
group
'
,
children
:
childrenImageLine
}
},
data
:
[
{
value
:
[
'
2020-03-01 12:00:00
'
,
'
2020-03-03 00:00:00
'
]
},
[
'
2020-03-03 01:00:00
'
,
'
2020-03-14 00:00:00
'
],
[
'
2020-03-14 08:03:00
'
,
'
2020-03-14 08:13:00
'
],
[
'
2020-03-15 02:00:00
'
,
'
2020-04-01 00:00:00
'
]
]
},
renderItem
:
getRenderItem
(
2.25
),
data
:
[
{
value
:
[
'
2020-03-02 08:00:00
'
,
'
2020-03-03 20:00:00
'
]
},
]
}
return
{
baseOption
}
},
]
}
return
{
baseOption
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录