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
52e53e39
Commit
52e53e39
authored
Feb 19, 2019
by
corpglory-dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review fixes
parent
0633dba3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
14 deletions
+36
-14
packages/grafana-ui/src/components/Piechart/Piechart.tsx
+8
-2
public/app/plugins/panel/piechart/PiechartPanel.tsx
+28
-12
No files found.
packages/grafana-ui/src/components/Piechart/Piechart.tsx
View file @
52e53e39
...
...
@@ -3,12 +3,18 @@ import React, { PureComponent } from 'react';
import
{
GrafanaThemeType
}
from
'../../types'
;
import
{
Themeable
}
from
'../../index'
;
export
interface
PieChartDataPoint
{
value
:
number
;
name
:
string
;
color
:
string
;
}
export
interface
Props
extends
Themeable
{
height
:
number
;
width
:
number
;
datapoints
:
PieChartDataPoint
[];
unit
:
string
;
value
:
number
;
pieType
:
string
;
format
:
string
;
stat
:
string
;
...
...
@@ -21,7 +27,7 @@ export class Piechart extends PureComponent<Props> {
static
defaultProps
=
{
pieType
:
'pie'
,
format
:
'short'
,
valueName
:
'current'
,
stat
:
'current'
,
strokeWidth
:
1
,
theme
:
GrafanaThemeType
.
Dark
,
};
...
...
public/app/plugins/panel/piechart/PiechartPanel.tsx
View file @
52e53e39
...
...
@@ -5,38 +5,54 @@ import React, { PureComponent } from 'react';
import
{
processTimeSeries
,
ThemeContext
}
from
'@grafana/ui'
;
// Components
import
{
Piechart
}
from
'@grafana/ui'
;
import
{
Piechart
,
PieChartDataPoint
}
from
'@grafana/ui'
;
// Types
import
{
PiechartOptions
}
from
'./types'
;
import
{
PanelProps
,
NullValueMode
,
TimeSeriesValue
}
from
'@grafana/ui/src/types'
;
import
{
PanelProps
,
NullValueMode
}
from
'@grafana/ui/src/types'
;
interface
Props
extends
PanelProps
<
PiechartOptions
>
{}
export
class
PiechartPanel
extends
PureComponent
<
Props
>
{
render
()
{
const
{
panelData
,
width
,
height
,
options
}
=
this
.
props
;
const
{
valueOptions
}
=
options
;
let
value
:
TimeSeriesValue
;
let
datapoints
:
PieChartDataPoint
[]
=
[];
if
(
panelData
.
timeSeries
)
{
const
vmSeries
=
processTimeSeries
({
timeSeries
:
panelData
.
timeSeries
,
nullValueMode
:
NullValueMode
.
Null
,
});
if
(
vmSeries
[
0
])
{
value
=
vmSeries
[
0
].
stats
[
options
.
stat
];
}
else
{
value
=
null
;
}
}
else
if
(
panelData
.
tableData
)
{
value
=
panelData
.
tableData
.
rows
[
0
].
find
(
prop
=>
prop
>
0
);
vmSeries
.
forEach
(
serie
=>
{
if
(
serie
)
{
datapoints
.
push
({
value
:
serie
.
stats
[
valueOptions
.
stat
],
// TODO: get name
name
:
'tmpName'
,
// TODO: add color option
color
:
'tmpColor'
});
}
});
}
// TODO: support table data
return
(
<
ThemeContext
.
Consumer
>
{
theme
=>
<
Piechart
value=
{
value
}
{
...
this
.
props
.
options
}
width=
{
width
}
height=
{
height
}
theme=
{
theme
}
/>
}
{
theme
=>
(
<
Piechart
width=
{
width
}
height=
{
height
}
datapoints=
{
datapoints
}
pieType=
{
options
.
pieType
}
unit=
{
options
.
unit
}
stat=
{
options
.
stat
}
strokeWidth=
{
options
.
strokeWidth
}
theme=
{
theme
}
/>
)
}
</
ThemeContext
.
Consumer
>
);
}
...
...
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