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
ffa68f6f
Unverified
Commit
ffa68f6f
authored
Jan 21, 2021
by
Dominik Prokop
Committed by
GitHub
Jan 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphNG: Disable Plot logging by default (#30390)
* Disable Plot loggging by default * Fix
parent
ffd39933
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
packages/grafana-ui/src/components/uPlot/Plot.tsx
+1
-0
packages/grafana-ui/src/components/uPlot/utils.ts
+11
-10
No files found.
packages/grafana-ui/src/components/uPlot/Plot.tsx
View file @
ffa68f6f
...
@@ -25,6 +25,7 @@ export const UPlotChart: React.FC<PlotProps> = (props) => {
...
@@ -25,6 +25,7 @@ export const UPlotChart: React.FC<PlotProps> = (props) => {
props
.
timeZone
,
props
.
timeZone
,
props
.
config
props
.
config
);
);
const
getPlotInstance
=
useCallback
(()
=>
{
const
getPlotInstance
=
useCallback
(()
=>
{
return
plotInstance
.
current
;
return
plotInstance
.
current
;
},
[]);
},
[]);
...
...
packages/grafana-ui/src/components/uPlot/utils.ts
View file @
ffa68f6f
...
@@ -2,13 +2,14 @@ import throttle from 'lodash/throttle';
...
@@ -2,13 +2,14 @@ import throttle from 'lodash/throttle';
import
{
Options
}
from
'uplot'
;
import
{
Options
}
from
'uplot'
;
import
{
PlotPlugin
,
PlotProps
}
from
'./types'
;
import
{
PlotPlugin
,
PlotProps
}
from
'./types'
;
const
LOGGING_ENABLED
=
false
;
const
ALLOWED_FORMAT_STRINGS_REGEX
=
/
\b(
YYYY|YY|MMMM|MMM|MM|M|DD|D|WWWW|WWW|HH|H|h|AA|aa|a|mm|m|ss|s|fff
)\b
/g
;
const
ALLOWED_FORMAT_STRINGS_REGEX
=
/
\b(
YYYY|YY|MMMM|MMM|MM|M|DD|D|WWWW|WWW|HH|H|h|AA|aa|a|mm|m|ss|s|fff
)\b
/g
;
export
const
timeFormatToTemplate
=
(
f
:
string
)
=>
{
export
function
timeFormatToTemplate
(
f
:
string
)
{
return
f
.
replace
(
ALLOWED_FORMAT_STRINGS_REGEX
,
(
match
)
=>
`{
${
match
}
}`
);
return
f
.
replace
(
ALLOWED_FORMAT_STRINGS_REGEX
,
(
match
)
=>
`{
${
match
}
}`
);
}
;
}
export
const
buildPlotConfig
=
(
props
:
PlotProps
,
plugins
:
Record
<
string
,
PlotPlugin
>
):
Options
=>
{
export
function
buildPlotConfig
(
props
:
PlotProps
,
plugins
:
Record
<
string
,
PlotPlugin
>
):
Options
{
return
{
return
{
width
:
props
.
width
,
width
:
props
.
width
,
height
:
props
.
height
,
height
:
props
.
height
,
...
@@ -27,10 +28,10 @@ export const buildPlotConfig = (props: PlotProps, plugins: Record<string, PlotPl
...
@@ -27,10 +28,10 @@ export const buildPlotConfig = (props: PlotProps, plugins: Record<string, PlotPl
hooks
:
p
[
1
].
hooks
,
hooks
:
p
[
1
].
hooks
,
})),
})),
hooks
:
{},
hooks
:
{},
}
as
any
;
}
as
Options
;
}
;
}
export
const
isPlottingTime
=
(
config
:
Options
)
=>
{
export
function
isPlottingTime
(
config
:
Options
)
{
let
isTimeSeries
=
false
;
let
isTimeSeries
=
false
;
if
(
!
config
.
scales
)
{
if
(
!
config
.
scales
)
{
...
@@ -46,17 +47,17 @@ export const isPlottingTime = (config: Options) => {
...
@@ -46,17 +47,17 @@ export const isPlottingTime = (config: Options) => {
}
}
return
isTimeSeries
;
return
isTimeSeries
;
}
;
}
// Dev helpers
// Dev helpers
export
const
throttledLog
=
throttle
((...
t
:
any
[])
=>
{
export
const
throttledLog
=
throttle
((...
t
:
any
[])
=>
{
console
.
log
(...
t
);
console
.
log
(...
t
);
},
500
);
},
500
);
export
const
pluginLog
=
(
id
:
string
,
throttle
=
false
,
...
t
:
any
[])
=>
{
export
function
pluginLog
(
id
:
string
,
throttle
=
false
,
...
t
:
any
[])
{
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
if
(
process
.
env
.
NODE_ENV
===
'production'
||
!
LOGGING_ENABLED
)
{
return
;
return
;
}
}
const
fn
=
throttle
?
throttledLog
:
console
.
log
;
const
fn
=
throttle
?
throttledLog
:
console
.
log
;
fn
(
`[Plugin:
${
id
}
]: `
,
...
t
);
fn
(
`[Plugin:
${
id
}
]: `
,
...
t
);
}
;
}
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