Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
graph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟@五瓣科技
graph
Commits
ccb19aed
Commit
ccb19aed
authored
Jul 19, 2022
by
wenli.huang@wuban.net.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
newup
parent
55888890
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
118 deletions
+122
-118
App.js
src/App.js
+122
-118
No files found.
src/App.js
View file @
ccb19aed
...
...
@@ -70,13 +70,6 @@ class App extends Component {
// .then((newData) => {
// let {Rows, AxisX, Links } = newData.result
// let {TopAxisX, BottomAxisX} = AxisX
// // allRows0Arr = [...allRows0Arr, ...Rows[0].slice(Rows[0].length-2, Rows[0].length-1)]
// // allRows1Arr = [...allRows1Arr, ...Rows[1].slice(Rows[1].length-2, Rows[1].length-1)]
// // allRows2Arr = [...allRows2Arr, ...Rows[2].slice(Rows[2].length-2, Rows[2].length-1)]
// // allTopAxisXArr = [...allTopAxisXArr, ...TopAxisX.slice(TopAxisX.length-2, TopAxisX.length-1)]
// // allBottomAxisXArr = [...allBottomAxisXArr, ...BottomAxisX.slice(BottomAxisX.length-2, BottomAxisX.length-1)]
// // allLinksArr = [...allLinksArr, ...Links.slice(Links.length-2, Links.length-1)]
// allRows0Arr = Rows[0]
// allRows1Arr = Rows[1]
// allRows2Arr = Rows[2]
...
...
@@ -98,24 +91,28 @@ class App extends Component {
var
chartDom
=
document
.
getElementById
(
'
main
'
);
var
myChart
=
echarts
.
init
(
chartDom
);
myChart
.
on
(
'
datazoom
'
,
function
(
params
){
// clearInterval(that.interval,console.log('滑动清除定时器'))
console
.
log
(
params
,
'
params
'
);
var
options
=
myChart
.
getOption
();
var
endValue
=
options
.
dataZoom
[
0
].
endValue
;
var
startValue
=
options
.
dataZoom
[
0
].
startValue
;
console
.
log
(
'
开始时间:
'
,
moment
(
startValue
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss:sss
'
))
console
.
log
(
'
当前开始时间:
'
,
moment
(
startValue
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss:sss
'
))
console
.
log
(
'
当前结束时间:
'
,
moment
(
endValue
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss:sss
'
))
// console.log(options,'options')
// console.log(options.series,'series')
// var min1
// var min2
var
min
=
0
var
endmin
=
0
var
min3
=
0
var
b
=
0
var
endBlock
=
0
;
var
maxB
=
0
var
minB
=
0
options
.
series
.
map
(
item
=>
{
item
.
markLine
.
data
.
forEach
(
item1
=>
{
item1
.
map
(
item2
=>
{
// console.log(item2.xAxis)
// console.log(item2.xAxis
,'1111'
)
if
(
item2
.
yAxis
===
'
Block
'
){
if
(
item2
.
label
!==
undefined
){
if
(
maxB
===
0
){
...
...
@@ -131,19 +128,28 @@ class App extends Component {
}
}
if
(
min
===
0
){
endmin
=
item2
.
xAxis
-
endValue
min
=
item2
.
xAxis
-
startValue
;
if
(
min
<
0
){
min
=
-
min
;
}
if
(
endmin
<
0
){
endmin
=-
endmin
}
if
(
item2
.
label
!==
undefined
){
b
=
item2
.
label
.
formatter
endBlock
=
item2
.
label
.
formatter
min3
=
item2
.
xAxis
}
}
else
{
var
min2
=
item2
.
xAxis
-
startValue
;
var
endmin2
=
item2
.
xAxis
-
endValue
;
if
(
min2
<
0
){
min2
=
-
min2
;
}
if
(
endmin2
<
0
){
endmin2
=-
endmin2
}
if
(
min
>
min2
){
min
=
min2
if
(
item2
.
label
!==
undefined
){
...
...
@@ -151,18 +157,25 @@ class App extends Component {
min3
=
item2
.
xAxis
}
}
if
(
endmin
>
endmin2
){
endmin
=
endmin2
if
(
item2
.
label
!==
undefined
){
endBlock
=
item2
.
label
.
formatter
// b=item2.label.formatter
min3
=
item2
.
xAxis
}
}
}
}
})
})
})
// console.log(min,'最小');
console
.
log
(
b
,
'
当前
'
);
console
.
log
(
maxB
,
'
max
'
);
console
.
log
(
minB
,
'
min
'
);
if
(
params
.
start
==
0
){
if
(
params
.
start
===
0
){
myChart
.
showLoading
()
that
.
setState
({
requestDuration
:
-
100
,
duration
:
-
10
,
},()
=>
{
fetch
(
`/api/graph_by_height_and_duration?height=
${
b
}
&duration=
${
that
.
state
.
requestDuration
}
`
,{
method
:
'
GET
'
,
headers
:{
...
...
@@ -171,15 +184,9 @@ class App extends Component {
})
.
then
(
res
=>
res
.
json
())
.
then
((
newData
)
=>
{
myChart
.
hideLoading
()
let
{
Rows
,
AxisX
,
Links
}
=
newData
.
result
let
{
TopAxisX
,
BottomAxisX
}
=
AxisX
// allRows0Arr = [...allRows0Arr, ...Rows[0].slice(Rows[0].length-2, Rows[0].length-1)]
// allRows1Arr = [...allRows1Arr, ...Rows[1].slice(Rows[1].length-2, Rows[1].length-1)]
// allRows2Arr = [...allRows2Arr, ...Rows[2].slice(Rows[2].length-2, Rows[2].length-1)]
// allTopAxisXArr = [...allTopAxisXArr, ...TopAxisX.slice(TopAxisX.length-2, TopAxisX.length-1)]
// allBottomAxisXArr = [...allBottomAxisXArr, ...BottomAxisX.slice(BottomAxisX.length-2, BottomAxisX.length-1)]
// allLinksArr = [...allLinksArr, ...Links.slice(Links.length-2, Links.length-1)]
allRows0Arr
=
Rows
[
0
]
allRows1Arr
=
Rows
[
1
]
allRows2Arr
=
Rows
[
2
]
...
...
@@ -197,28 +204,48 @@ class App extends Component {
newData
.
result
.
Links
=
allLinksArr
that
.
initChart
(
newData
,
1
)
})
})
console
.
log
(
that
.
state
.
requestDuration
,
that
.
state
.
duration
,
'
负负负
'
)
}
if
(
params
.
end
===
100
){
myChart
.
showLoading
()
// console.log(that.state.requestDuration,that.state.duration,'requestAnimationFrame','duration')
that
.
setState
({
requestDuration
:
100
,
duration
:
10
,
},()
=>
{
fetch
(
`/api/graph_by_height_and_duration?height=
${
endBlock
}
&duration=
${
that
.
state
.
requestDuration
}
`
,{
method
:
'
GET
'
,
headers
:{
'
Content-Type
'
:
'
application/json;charset=UTF-8
'
},
})
.
then
(
res
=>
res
.
json
())
.
then
((
newData
)
=>
{
myChart
.
hideLoading
()
let
{
Rows
,
AxisX
,
Links
}
=
newData
.
result
let
{
TopAxisX
,
BottomAxisX
}
=
AxisX
allRows0Arr
=
Rows
[
0
]
allRows1Arr
=
Rows
[
1
]
allRows2Arr
=
Rows
[
2
]
allTopAxisXArr
=
TopAxisX
allBottomAxisXArr
=
BottomAxisX
allLinksArr
=
Links
// console.log(moment(min3/1000000).format('YYYY-MM-DD HH:mm:ss'),'最小')
// if(params.start<=40){
// console.log("该往后加载数据了")
// fetch(`/api/graph_by_height_and_duration?height=${b}&duration=${that.state.requestDuration}`,{
// method:'GET',
// headers:{
// 'Content-Type':'application/json;charset=UTF-8'
// },
// })
// .then(res =>res.json())
// .then((newDatas) => {
// console.log(newDatas.result)
// // console.log(moment(newDatas.result.AxisX.BlockTime/1000000).format('YYYY-MM-DD HH:mm:ss'))
// })
// }
newData
.
result
.
Rows
[
0
]
=
allRows0Arr
newData
.
result
.
Rows
[
1
]
=
allRows1Arr
newData
.
result
.
Rows
[
2
]
=
allRows2Arr
newData
.
result
.
AxisX
.
TopAxisX
=
allTopAxisXArr
newData
.
result
.
AxisX
.
BottomAxisX
=
allBottomAxisXArr
newData
.
result
.
Links
=
allLinksArr
that
.
initChart
(
newData
,
1
)
})
console
.
log
(
that
.
state
.
requestDuration
,
that
.
state
.
duration
,
'
正正正
'
)
})
}
})
})
})
...
...
@@ -232,7 +259,6 @@ class App extends Component {
var
myChart
=
echarts
.
init
(
chartDom
);
var
maxtime
=
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
)
maxtime
.
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
// console.log(maxtime.format('YYYY-MM-DD HH:mm:ss'))
maxtime
.
add
(
this
.
state
.
duration
,
'
seconds
'
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
maxtime
.
unix
()
var
mintime
=
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
)
...
...
@@ -258,7 +284,7 @@ class App extends Component {
]
})
data
.
result
.
AxisX
.
BottomAxisX
.
map
(
item
=>
{
markline
.
push
(
[
markline
.
push
([
{
// name: 'start',
xAxis
:
item
.
Time
,
...
...
@@ -276,16 +302,21 @@ class App extends Component {
xAxis
:
item
.
Time
,
yAxis
:
'
Round
'
},
]
)
])
})
console
.
log
(
'
请求requestDuration
'
,
this
.
state
.
requestDuration
,
'
时间间隔:
'
,
this
.
state
.
duration
)
if
(
this
.
state
.
duration
<
0
){
maxtime
=
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
)
mintime
=
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
)
// mintime.add(-(this.state.duration),'seconds').format('YYYY-MM-DD HH:mm:ss')
mintime
.
subtract
(
-
(
this
.
state
.
duration
),
'
seconds
'
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
}
if
(
this
.
state
.
duration
>
0
){
mintime
=
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
);
maxtime
=
moment
(
data
.
result
.
AxisX
.
BlockTime
/
1000000
)
maxtime
.
add
(
this
.
state
.
requestDuration
,
'
seconds
'
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
// console.log(mintime,'最小',maxtime,'最大');
}
var
source
=
data
.
result
.
Rows
var
target
=
[];
...
...
@@ -306,9 +337,6 @@ class App extends Component {
}
target
.
push
(
list
);
}
// var chartDom = document.getElementById('main');
// var myChart = echarts.init(chartDom);
var
option
;
const
series
=
[];
this
.
state
.
AxisY
.
forEach
(
function
(
type
)
{
...
...
@@ -407,23 +435,16 @@ class App extends Component {
{
type
:
'
inside
'
,
startValue
:
mintime
.
unix
()
*
1000000000
,
endValue
:
maxtime
.
unix
()
*
1000000000
,
// endValue:maxtime.unix()*1000000000,
endValue
:
this
.
state
.
duration
<
0
?
maxtime
.
unix
()
*
1000000000
:
(
maxtime
.
subtract
(
90
,
'
second
'
)).
unix
()
*
1000000000
,
disabled
:
false
,
zoomLock
:
true
,
// xAxisIndex: [0],
// labelFormatter: function (dataIndex) {
// console.log(dataIndex,'dd')
// }
},
{
// start: 40,
// end:60,
// startValue:mintime.unix()*1000000000,
// endValue:maxtime.unix()*1000000000,
disabled
:
false
,
zoomLock
:
true
,
},
],
xAxis
:
[
{
...
...
@@ -433,9 +454,11 @@ class App extends Component {
return
moment
(
parseInt
(
value
/
1000000
)).
format
(
'
YYYY-MM-DD HH:mm:ss
'
)
})
},
// max:maxtime.add(5,'seconds').unix()*1000000000,
max
:
maxtime
.
unix
()
*
1000000000
,
min
:
mintime
.
subtract
(
100
,
'
seconds
'
).
unix
()
*
1000000000
,
// max:maxtime.unix()*1000000000,
// min:mintime.subtract(100,'seconds').unix()*1000000000,
max
:
this
.
state
.
duration
<
0
?
maxtime
.
unix
()
*
1000000000
:
maxtime
.
add
(
100
,
'
second
'
).
unix
()
*
1000000000
,
min
:
this
.
state
.
duration
<
0
?
mintime
.
subtract
(
100
,
'
second
'
).
unix
()
*
1000000000
:
mintime
.
unix
()
*
1000000000
,
// splitNumber:10,
axisLine
:{
show
:
true
,
...
...
@@ -445,8 +468,6 @@ class App extends Component {
alignWithLabel
:
true
,
},
},
// 上边的轴指的是之前block
{
axisLine
:{
show
:
true
,
...
...
@@ -459,24 +480,6 @@ class App extends Component {
alignWithLabel
:
true
,
},
},
// {
// axisLine:{
// show: true,
// symbol: ['none', 'arrow']
// },
// offset:-550,
// axisLabel: {
// formatter: (function(value){
// return moment(parseInt(value/1000000)).format('YYYY-MM-DD HH:mm:ss')
// })
// },
// max:maxtime.unix()*1000000000,
// min:mintime.subtract(100,'seconds').unix()*1000000000,
// axisTick: {
// alignWithLabel:true,
// },
// },
],
yAxis
:
{
type
:
'
category
'
,
...
...
@@ -510,17 +513,18 @@ class App extends Component {
dataZoom
:
{}
}
},
// dataZoom: {
// type: 'inside'
// },
series
:
series
,
};
console
.
log
(
'
datazoom开始
'
,
moment
((
option
.
dataZoom
[
0
].
startValue
)
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
),
'
dataZoom结束
'
,
moment
((
option
.
dataZoom
[
0
].
endValue
)
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
))
console
.
log
(
'
主轴开始
'
,
moment
((
option
.
xAxis
[
0
].
min
)
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
),
'
主轴结束
'
,
moment
((
option
.
xAxis
[
0
].
max
)
/
1000000
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
));
myChart
.
setOption
(
option
);
//
// window.addEventListener("resize", function () {
// myChart.resize(); //使图表自适应窗口的大小
// })
this
.
extension
(
myChart
);
}
extension
(
myChart
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment