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
7974972d
Unverified
Commit
7974972d
authored
Dec 08, 2020
by
Ryan McKinley
Committed by
GitHub
Dec 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphNG: fix bars migration and support color and linewidth (#29697)
parent
3bd4b875
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
189 additions
and
9 deletions
+189
-9
public/app/plugins/panel/graph3/__snapshots__/migrations.test.ts.snap
+52
-2
public/app/plugins/panel/graph3/migrations.test.ts
+102
-0
public/app/plugins/panel/graph3/migrations.ts
+35
-7
No files found.
public/app/plugins/panel/graph3/__snapshots__/migrations.test.ts.snap
View file @
7974972d
...
@@ -35,7 +35,8 @@ Object {
...
@@ -35,7 +35,8 @@ Object {
"drawStyle": "line",
"drawStyle": "line",
"fillOpacity": 0.5,
"fillOpacity": 0.5,
"lineInterpolation": "stepAfter",
"lineInterpolation": "stepAfter",
"pointSize": 2,
"lineWidth": 1,
"pointSize": 6,
"showPoints": "never",
"showPoints": "never",
"spanNulls": true,
"spanNulls": true,
},
},
...
@@ -58,6 +59,54 @@ Object {
...
@@ -58,6 +59,54 @@ Object {
}
}
`;
`;
exports[`Graph Migrations stepped line 1`] = `
Object {
"fieldConfig": Object {
"defaults": Object {
"custom": Object {
"axisPlacement": "auto",
"drawStyle": "line",
"fillOpacity": 0.5,
"lineInterpolation": "stepAfter",
"lineWidth": 5,
"pointSize": 6,
"showPoints": "never",
"spanNulls": true,
},
"nullValueMode": "null",
"unit": "short",
},
"overrides": Array [
Object {
"matcher": Object {
"id": "byName",
"options": "A-series",
},
"properties": Array [
Object {
"id": "color",
"value": Object {
"fixedColor": "red",
"mode": "fixed",
},
},
],
},
],
},
"options": Object {
"graph": Object {},
"legend": Object {
"displayMode": "list",
"placement": "bottom",
},
"tooltipOptions": Object {
"mode": "single",
},
},
}
`;
exports[`Graph Migrations twoYAxis 1`] = `
exports[`Graph Migrations twoYAxis 1`] = `
Object {
Object {
"fieldConfig": Object {
"fieldConfig": Object {
...
@@ -67,7 +116,8 @@ Object {
...
@@ -67,7 +116,8 @@ Object {
"axisPlacement": "auto",
"axisPlacement": "auto",
"drawStyle": "line",
"drawStyle": "line",
"fillOpacity": 0.1,
"fillOpacity": 0.1,
"pointSize": 2,
"lineWidth": 1,
"pointSize": 6,
"showPoints": "never",
"showPoints": "never",
"spanNulls": true,
"spanNulls": true,
},
},
...
...
public/app/plugins/panel/graph3/migrations.test.ts
View file @
7974972d
...
@@ -30,6 +30,15 @@ describe('Graph Migrations', () => {
...
@@ -30,6 +30,15 @@ describe('Graph Migrations', () => {
panel
.
options
=
graphPanelChangedHandler
(
panel
,
'graph'
,
old
);
panel
.
options
=
graphPanelChangedHandler
(
panel
,
'graph'
,
old
);
expect
(
panel
).
toMatchSnapshot
();
expect
(
panel
).
toMatchSnapshot
();
});
});
it
(
'stepped line'
,
()
=>
{
const
old
:
any
=
{
angular
:
stepedColordLine
,
};
const
panel
=
{}
as
PanelModel
;
panel
.
options
=
graphPanelChangedHandler
(
panel
,
'graph'
,
old
);
expect
(
panel
).
toMatchSnapshot
();
});
});
});
const
stairscase
=
{
const
stairscase
=
{
...
@@ -201,3 +210,96 @@ const twoYAxis = {
...
@@ -201,3 +210,96 @@ const twoYAxis = {
timeShift
:
null
,
timeShift
:
null
,
datasource
:
null
,
datasource
:
null
,
};
};
const
stepedColordLine
=
{
aliasColors
:
{
'A-series'
:
'red'
,
},
dashLength
:
10
,
fieldConfig
:
{
defaults
:
{
custom
:
{},
},
overrides
:
[],
},
fill
:
5
,
gridPos
:
{
h
:
9
,
w
:
12
,
x
:
0
,
y
:
0
,
},
id
:
2
,
legend
:
{
avg
:
false
,
current
:
false
,
max
:
false
,
min
:
false
,
show
:
true
,
total
:
false
,
values
:
false
,
},
lines
:
true
,
linewidth
:
5
,
maxDataPoints
:
20
,
nullPointMode
:
'null'
,
options
:
{
alertThreshold
:
true
,
},
pluginVersion
:
'7.4.0-pre'
,
pointradius
:
2
,
renderer
:
'flot'
,
seriesOverrides
:
[],
spaceLength
:
10
,
steppedLine
:
true
,
thresholds
:
[],
timeRegions
:
[],
title
:
'Panel Title'
,
tooltip
:
{
shared
:
true
,
sort
:
0
,
value_type
:
'individual'
,
},
type
:
'graph'
,
xaxis
:
{
buckets
:
null
,
mode
:
'time'
,
name
:
null
,
show
:
true
,
values
:
[],
},
yaxes
:
[
{
$
$hashKey
:
'object:38'
,
format
:
'short'
,
label
:
null
,
logBase
:
1
,
max
:
null
,
min
:
null
,
show
:
true
,
},
{
$
$hashKey
:
'object:39'
,
format
:
'short'
,
label
:
null
,
logBase
:
1
,
max
:
null
,
min
:
null
,
show
:
true
,
},
],
yaxis
:
{
align
:
false
,
alignLevel
:
null
,
},
bars
:
false
,
dashes
:
false
,
fillGradient
:
0
,
hiddenSeries
:
false
,
percentage
:
false
,
points
:
false
,
stack
:
false
,
timeFrom
:
null
,
timeShift
:
null
,
datasource
:
null
,
};
public/app/plugins/panel/graph3/migrations.ts
View file @
7974972d
...
@@ -7,6 +7,8 @@ import {
...
@@ -7,6 +7,8 @@ import {
ConfigOverrideRule
,
ConfigOverrideRule
,
FieldMatcherID
,
FieldMatcherID
,
DynamicConfigValue
,
DynamicConfigValue
,
FieldConfigProperty
,
FieldColorModeId
,
}
from
'@grafana/data'
;
}
from
'@grafana/data'
;
import
{
GraphFieldConfig
,
LegendDisplayMode
}
from
'@grafana/ui'
;
import
{
GraphFieldConfig
,
LegendDisplayMode
}
from
'@grafana/ui'
;
import
{
AxisPlacement
,
DrawStyle
,
LineInterpolation
,
PointVisibility
}
from
'@grafana/ui/src/components/uPlot/config'
;
import
{
AxisPlacement
,
DrawStyle
,
LineInterpolation
,
PointVisibility
}
from
'@grafana/ui/src/components/uPlot/config'
;
...
@@ -54,6 +56,30 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
...
@@ -54,6 +56,30 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
// "linewidth": 2
// "linewidth": 2
// }
// }
// ],
// ],
if
(
angular
.
aliasColors
)
{
for
(
const
alias
of
Object
.
keys
(
angular
.
aliasColors
))
{
const
color
=
angular
.
aliasColors
[
alias
];
if
(
color
)
{
overrides
.
push
({
matcher
:
{
id
:
FieldMatcherID
.
byName
,
options
:
alias
,
},
properties
:
[
{
id
:
FieldConfigProperty
.
Color
,
value
:
{
mode
:
FieldColorModeId
.
Fixed
,
fixedColor
:
color
,
},
},
],
});
}
}
}
if
(
angular
.
seriesOverrides
?.
length
)
{
if
(
angular
.
seriesOverrides
?.
length
)
{
for
(
const
seriesOverride
of
angular
.
seriesOverrides
)
{
for
(
const
seriesOverride
of
angular
.
seriesOverrides
)
{
if
(
!
seriesOverride
.
alias
)
{
if
(
!
seriesOverride
.
alias
)
{
...
@@ -109,7 +135,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
...
@@ -109,7 +135,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
});
});
}
}
break
;
break
;
case
'line
W
idth'
:
case
'line
w
idth'
:
rule
.
properties
.
push
({
rule
.
properties
.
push
({
id
:
'custom.lineWidth'
,
id
:
'custom.lineWidth'
,
value
:
v
,
value
:
v
,
...
@@ -118,7 +144,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
...
@@ -118,7 +144,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
case
'pointradius'
:
case
'pointradius'
:
rule
.
properties
.
push
({
rule
.
properties
.
push
({
id
:
'custom.pointSize'
,
id
:
'custom.pointSize'
,
value
:
v
,
value
:
2
+
v
*
2
,
});
});
break
;
break
;
default
:
default
:
...
@@ -138,12 +164,11 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
...
@@ -138,12 +164,11 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
}
else
if
(
graph
.
drawStyle
!==
DrawStyle
.
Points
)
{
}
else
if
(
graph
.
drawStyle
!==
DrawStyle
.
Points
)
{
graph
.
showPoints
=
PointVisibility
.
Never
;
graph
.
showPoints
=
PointVisibility
.
Never
;
}
}
if
(
graph
.
drawStyle
===
DrawStyle
.
Bars
)
{
graph
.
fillOpacity
=
1.0
;
// bars were always
}
graph
.
lineWidth
=
angular
.
lineWidth
;
graph
.
lineWidth
=
angular
.
linewidth
;
graph
.
pointSize
=
angular
.
pointradius
;
if
(
isNumber
(
angular
.
pointradius
))
{
graph
.
pointSize
=
2
+
angular
.
pointradius
*
2
;
}
if
(
isNumber
(
angular
.
fill
))
{
if
(
isNumber
(
angular
.
fill
))
{
graph
.
fillOpacity
=
angular
.
fill
/
10
;
// fill is 0-10
graph
.
fillOpacity
=
angular
.
fill
/
10
;
// fill is 0-10
}
}
...
@@ -151,6 +176,9 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
...
@@ -151,6 +176,9 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
if
(
angular
.
steppedLine
)
{
if
(
angular
.
steppedLine
)
{
graph
.
lineInterpolation
=
LineInterpolation
.
StepAfter
;
graph
.
lineInterpolation
=
LineInterpolation
.
StepAfter
;
}
}
if
(
graph
.
drawStyle
===
DrawStyle
.
Bars
)
{
graph
.
fillOpacity
=
1.0
;
// bars were always
}
y1
.
custom
=
omitBy
(
graph
,
isNil
);
y1
.
custom
=
omitBy
(
graph
,
isNil
);
y1
.
nullValueMode
=
angular
.
nullPointMode
as
NullValueMode
;
y1
.
nullValueMode
=
angular
.
nullPointMode
as
NullValueMode
;
...
...
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