Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
8f26fe0f
Unverified
Commit
8f26fe0f
authored
Dec 10, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix time regions bugs
parent
acf24bd6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
public/app/plugins/panel/graph/specs/time_region_manager.test.ts
+36
-0
public/app/plugins/panel/graph/time_region_manager.ts
+8
-0
No files found.
public/app/plugins/panel/graph/specs/time_region_manager.test.ts
View file @
8f26fe0f
...
@@ -238,6 +238,42 @@ describe('TimeRegionManager', () => {
...
@@ -238,6 +238,42 @@ describe('TimeRegionManager', () => {
});
});
});
});
plotOptionsScenario
(
'for day of week from/to time region'
,
ctx
=>
{
const
regions
=
[{
fromDayOfWeek
:
7
,
from
:
'23:00'
,
toDayOfWeek
:
1
,
to
:
'01:40'
,
fill
:
true
,
colorMode
:
'red'
}];
const
from
=
moment
(
'2018-12-07T12:51:19+01:00'
);
const
to
=
moment
(
'2018-12-10T13:51:29+01:00'
);
ctx
.
setup
(
regions
,
from
,
to
);
it
(
'should add 1 marking'
,
()
=>
{
expect
(
ctx
.
options
.
grid
.
markings
.
length
).
toBe
(
1
);
});
it
(
'should add one fill between sunday 23:00 and monday 01:40'
,
()
=>
{
const
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
moment
(
markings
[
0
].
xaxis
.
from
).
format
()).
toBe
(
moment
(
'2018-12-10T00:00:00+01:00'
).
format
());
expect
(
moment
(
markings
[
0
].
xaxis
.
to
).
format
()).
toBe
(
moment
(
'2018-12-10T02:40:00+01:00'
).
format
());
});
});
plotOptionsScenario
(
'for day of week from/to time region'
,
ctx
=>
{
const
regions
=
[{
fromDayOfWeek
:
6
,
from
:
'03:00'
,
toDayOfWeek
:
7
,
to
:
'02:00'
,
fill
:
true
,
colorMode
:
'red'
}];
const
from
=
moment
(
'2018-12-07T12:51:19+01:00'
);
const
to
=
moment
(
'2018-12-10T13:51:29+01:00'
);
ctx
.
setup
(
regions
,
from
,
to
);
it
(
'should add 1 marking'
,
()
=>
{
expect
(
ctx
.
options
.
grid
.
markings
.
length
).
toBe
(
1
);
});
it
(
'should add one fill between saturday 03:00 and sunday 02:00'
,
()
=>
{
const
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
moment
(
markings
[
0
].
xaxis
.
from
).
format
()).
toBe
(
moment
(
'2018-12-08T04:00:00+01:00'
).
format
());
expect
(
moment
(
markings
[
0
].
xaxis
.
to
).
format
()).
toBe
(
moment
(
'2018-12-09T03:00:00+01:00'
).
format
());
});
});
plotOptionsScenario
(
'for day of week from/to time region with daylight saving time'
,
ctx
=>
{
plotOptionsScenario
(
'for day of week from/to time region with daylight saving time'
,
ctx
=>
{
const
regions
=
[{
fromDayOfWeek
:
7
,
from
:
'20:00'
,
toDayOfWeek
:
7
,
to
:
'23:00'
,
fill
:
true
,
colorMode
:
'red'
}];
const
regions
=
[{
fromDayOfWeek
:
7
,
from
:
'20:00'
,
toDayOfWeek
:
7
,
to
:
'23:00'
,
fill
:
true
,
colorMode
:
'red'
}];
const
from
=
moment
(
'2018-03-17T06:00:00+01:00'
);
const
from
=
moment
(
'2018-03-17T06:00:00+01:00'
);
...
...
public/app/plugins/panel/graph/time_region_manager.ts
View file @
8f26fe0f
...
@@ -169,8 +169,16 @@ export class TimeRegionManager {
...
@@ -169,8 +169,16 @@ export class TimeRegionManager {
fromEnd
.
add
(
hRange
.
to
.
h
-
hRange
.
from
.
h
,
'hours'
);
fromEnd
.
add
(
hRange
.
to
.
h
-
hRange
.
from
.
h
,
'hours'
);
}
else
if
(
hRange
.
from
.
h
+
hRange
.
to
.
h
<
23
)
{
}
else
if
(
hRange
.
from
.
h
+
hRange
.
to
.
h
<
23
)
{
fromEnd
.
add
(
hRange
.
to
.
h
,
'hours'
);
fromEnd
.
add
(
hRange
.
to
.
h
,
'hours'
);
while
(
fromEnd
.
hour
()
!==
hRange
.
to
.
h
)
{
fromEnd
.
add
(
-
1
,
'hours'
);
}
}
else
{
}
else
{
fromEnd
.
add
(
24
-
hRange
.
from
.
h
,
'hours'
);
fromEnd
.
add
(
24
-
hRange
.
from
.
h
,
'hours'
);
while
(
fromEnd
.
hour
()
!==
hRange
.
to
.
h
)
{
fromEnd
.
add
(
1
,
'hours'
);
}
}
}
fromEnd
.
set
(
'minute'
,
hRange
.
to
.
m
);
fromEnd
.
set
(
'minute'
,
hRange
.
to
.
m
);
...
...
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