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
2f92794c
Unverified
Commit
2f92794c
authored
Dec 04, 2020
by
Leon Sorokin
Committed by
GitHub
Dec 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphNG: rename GraphMode to DrawStyle (#29623)
parent
a36bd895
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
31 deletions
+30
-31
packages/grafana-ui/src/components/GraphNG/GraphNG.tsx
+4
-4
packages/grafana-ui/src/components/uPlot/Plot.test.tsx
+2
-2
packages/grafana-ui/src/components/uPlot/config.ts
+7
-8
packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts
+2
-2
packages/grafana-ui/src/components/uPlot/config/UPlotSeriesBuilder.ts
+7
-7
public/app/plugins/panel/graph3/module.tsx
+8
-8
No files found.
packages/grafana-ui/src/components/GraphNG/GraphNG.tsx
View file @
2f92794c
...
...
@@ -12,7 +12,7 @@ import {
import
{
alignDataFrames
}
from
'./utils'
;
import
{
UPlotChart
}
from
'../uPlot/Plot'
;
import
{
PlotProps
}
from
'../uPlot/types'
;
import
{
AxisPlacement
,
GraphFieldConfig
,
GraphMod
e
,
PointMode
}
from
'../uPlot/config'
;
import
{
AxisPlacement
,
GraphFieldConfig
,
DrawStyl
e
,
PointMode
}
from
'../uPlot/config'
;
import
{
useTheme
}
from
'../../themes'
;
import
{
VizLayout
}
from
'../VizLayout/VizLayout'
;
import
{
LegendDisplayMode
,
LegendItem
,
LegendOptions
}
from
'../Legend/Legend'
;
...
...
@@ -34,7 +34,7 @@ export interface GraphNGProps extends Omit<PlotProps, 'data' | 'config'> {
}
const
defaultConfig
:
GraphFieldConfig
=
{
mode
:
GraphMod
e
.
Line
,
drawStyle
:
DrawStyl
e
.
Line
,
points
:
PointMode
.
Auto
,
axisPlacement
:
AxisPlacement
.
Auto
,
};
...
...
@@ -134,11 +134,11 @@ export const GraphNG: React.FC<GraphNGProps> = ({
const
colorMode
=
getFieldColorModeForField
(
field
);
const
seriesColor
=
colorMode
.
getCalculator
(
field
,
theme
)(
0
,
0
);
const
pointsMode
=
customConfig
.
mode
===
GraphMod
e
.
Points
?
PointMode
.
Always
:
customConfig
.
points
;
const
pointsMode
=
customConfig
.
drawStyle
===
DrawStyl
e
.
Points
?
PointMode
.
Always
:
customConfig
.
points
;
builder
.
addSeries
({
scaleKey
,
mode
:
customConfig
.
mod
e
!
,
drawStyle
:
customConfig
.
drawStyl
e
!
,
lineColor
:
seriesColor
,
lineWidth
:
customConfig
.
lineWidth
,
lineInterpolation
:
customConfig
.
lineInterpolation
,
...
...
packages/grafana-ui/src/components/uPlot/Plot.test.tsx
View file @
2f92794c
...
...
@@ -2,7 +2,7 @@ import React from 'react';
import
{
UPlotChart
}
from
'./Plot'
;
import
{
act
,
render
}
from
'@testing-library/react'
;
import
{
ArrayVector
,
dateTime
,
FieldConfig
,
FieldType
,
MutableDataFrame
}
from
'@grafana/data'
;
import
{
GraphFieldConfig
,
GraphMod
e
}
from
'../uPlot/config'
;
import
{
GraphFieldConfig
,
DrawStyl
e
}
from
'../uPlot/config'
;
import
uPlot
from
'uplot'
;
import
createMockRaf
from
'mock-raf'
;
import
{
UPlotConfigBuilder
}
from
'./config/UPlotConfigBuilder'
;
...
...
@@ -40,7 +40,7 @@ const mockData = () => {
values
:
new
ArrayVector
([
10
,
20
,
5
]),
config
:
{
custom
:
{
mode
:
GraphMod
e
.
Line
,
drawStyle
:
DrawStyl
e
.
Line
,
},
}
as
FieldConfig
<
GraphFieldConfig
>
,
});
...
...
packages/grafana-ui/src/components/uPlot/config.ts
View file @
2f92794c
...
...
@@ -15,7 +15,7 @@ export enum PointMode {
Always
=
'always'
,
}
export
enum
GraphMod
e
{
export
enum
DrawStyl
e
{
Line
=
'line'
,
// default
Bars
=
'bars'
,
// will also have a gap percent
Points
=
'points'
,
// Only show points
...
...
@@ -54,17 +54,16 @@ export interface AxisConfig {
}
export
interface
GraphFieldConfig
extends
LineConfig
,
AreaConfig
,
PointsConfig
,
AxisConfig
{
mode
?:
GraphMode
;
drawStyle
?:
DrawStyle
;
spanNulls
?:
boolean
;
}
export
const
graphFieldOptions
=
{
mod
e
:
[
{
label
:
'Lines'
,
value
:
GraphMod
e
.
Line
},
{
label
:
'Bars'
,
value
:
GraphMod
e
.
Bars
},
{
label
:
'Points'
,
value
:
GraphMod
e
.
Points
},
]
as
Array
<
SelectableValue
<
GraphMod
e
>>
,
drawStyl
e
:
[
{
label
:
'Lines'
,
value
:
DrawStyl
e
.
Line
},
{
label
:
'Bars'
,
value
:
DrawStyl
e
.
Bars
},
{
label
:
'Points'
,
value
:
DrawStyl
e
.
Points
},
]
as
Array
<
SelectableValue
<
DrawStyl
e
>>
,
lineInterpolation
:
[
{
label
:
'Linear'
,
value
:
LineInterpolation
.
Linear
},
...
...
packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts
View file @
2f92794c
...
...
@@ -3,7 +3,7 @@
import
{
UPlotConfigBuilder
}
from
'./UPlotConfigBuilder'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
import
{
expect
}
from
'../../../../../../public/test/lib/common'
;
import
{
AxisPlacement
,
GraphMod
e
,
PointMode
}
from
'../config'
;
import
{
AxisPlacement
,
DrawStyl
e
,
PointMode
}
from
'../config'
;
describe
(
'UPlotConfigBuilder'
,
()
=>
{
describe
(
'scales config'
,
()
=>
{
...
...
@@ -121,7 +121,7 @@ describe('UPlotConfigBuilder', () => {
it
(
'allows series configuration'
,
()
=>
{
const
builder
=
new
UPlotConfigBuilder
();
builder
.
addSeries
({
mode
:
GraphMod
e
.
Line
,
drawStyle
:
DrawStyl
e
.
Line
,
scaleKey
:
'scale-x'
,
fillColor
:
'#ff0000'
,
fillOpacity
:
0.5
,
...
...
packages/grafana-ui/src/components/uPlot/config/UPlotSeriesBuilder.ts
View file @
2f92794c
import
tinycolor
from
'tinycolor2'
;
import
uPlot
,
{
Series
}
from
'uplot'
;
import
{
GraphMod
e
,
LineConfig
,
AreaConfig
,
PointsConfig
,
PointMode
,
LineInterpolation
}
from
'../config'
;
import
{
DrawStyl
e
,
LineConfig
,
AreaConfig
,
PointsConfig
,
PointMode
,
LineInterpolation
}
from
'../config'
;
import
{
barsBuilder
,
smoothBuilder
,
stepBeforeBuilder
,
stepAfterBuilder
}
from
'../paths'
;
import
{
PlotConfigBuilder
}
from
'../types'
;
export
interface
SeriesProps
extends
LineConfig
,
AreaConfig
,
PointsConfig
{
mode
:
GraphMod
e
;
drawStyle
:
DrawStyl
e
;
scaleKey
:
string
;
}
export
class
UPlotSeriesBuilder
extends
PlotConfigBuilder
<
SeriesProps
,
Series
>
{
getConfig
()
{
const
{
mod
e
,
drawStyl
e
,
lineInterpolation
,
lineColor
,
lineWidth
,
...
...
@@ -26,7 +26,7 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
let
lineConfig
:
Partial
<
Series
>
=
{};
if
(
mode
===
GraphMod
e
.
Points
)
{
if
(
drawStyle
===
DrawStyl
e
.
Points
)
{
lineConfig
.
paths
=
()
=>
null
;
}
else
{
lineConfig
.
stroke
=
lineColor
;
...
...
@@ -41,9 +41,9 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
)
=>
{
let
pathsBuilder
=
self
.
paths
;
if
(
mode
===
GraphMod
e
.
Bars
)
{
if
(
drawStyle
===
DrawStyl
e
.
Bars
)
{
pathsBuilder
=
barsBuilder
;
}
else
if
(
mode
===
GraphMod
e
.
Line
)
{
}
else
if
(
drawStyle
===
DrawStyl
e
.
Line
)
{
if
(
lineInterpolation
===
LineInterpolation
.
StepBefore
)
{
pathsBuilder
=
stepBeforeBuilder
;
}
else
if
(
lineInterpolation
===
LineInterpolation
.
StepAfter
)
{
...
...
@@ -67,7 +67,7 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
// we cannot set points.show property above (even to undefined) as that will clear uPlot's default auto behavior
if
(
points
===
PointMode
.
Auto
)
{
if
(
mode
===
GraphMod
e
.
Bars
)
{
if
(
drawStyle
===
DrawStyl
e
.
Bars
)
{
pointsConfig
.
points
!
.
show
=
false
;
}
}
else
if
(
points
===
PointMode
.
Never
)
{
...
...
public/app/plugins/panel/graph3/module.tsx
View file @
2f92794c
...
...
@@ -3,7 +3,7 @@ import { LegendDisplayMode } from '@grafana/ui';
import
{
GraphFieldConfig
,
PointMode
,
GraphMod
e
,
DrawStyl
e
,
AxisPlacement
,
graphFieldOptions
,
}
from
'@grafana/ui/src/components/uPlot/config'
;
...
...
@@ -25,11 +25,11 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(GraphPanel)
useCustomConfig
:
builder
=>
{
builder
.
addRadio
({
path
:
'
mod
e'
,
name
:
'
Display
'
,
defaultValue
:
graphFieldOptions
.
mod
e
[
0
].
value
,
path
:
'
drawStyl
e'
,
name
:
'
Style
'
,
defaultValue
:
graphFieldOptions
.
drawStyl
e
[
0
].
value
,
settings
:
{
options
:
graphFieldOptions
.
mod
e
,
options
:
graphFieldOptions
.
drawStyl
e
,
},
})
.
addRadio
({
...
...
@@ -39,7 +39,7 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(GraphPanel)
settings
:
{
options
:
graphFieldOptions
.
lineInterpolation
,
},
showIf
:
c
=>
c
.
mode
===
GraphMod
e
.
Line
,
showIf
:
c
=>
c
.
drawStyle
===
DrawStyl
e
.
Line
,
})
.
addSliderInput
({
path
:
'lineWidth'
,
...
...
@@ -50,7 +50,7 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(GraphPanel)
max
:
10
,
step
:
1
,
},
showIf
:
c
=>
c
.
mode
!==
GraphMod
e
.
Points
,
showIf
:
c
=>
c
.
drawStyle
!==
DrawStyl
e
.
Points
,
})
.
addSliderInput
({
path
:
'fillOpacity'
,
...
...
@@ -61,7 +61,7 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(GraphPanel)
max
:
1
,
step
:
0.1
,
},
showIf
:
c
=>
c
.
mode
!==
GraphMod
e
.
Points
,
showIf
:
c
=>
c
.
drawStyle
!==
DrawStyl
e
.
Points
,
})
.
addRadio
({
path
:
'points'
,
...
...
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