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