Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_22812535
incubator-superset
提交
80518186
I
incubator-superset
项目概览
qq_22812535
/
incubator-superset
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-superset
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
80518186
编写于
1月 11, 2019
作者:
M
Maxime Beauchemin
提交者:
GitHub
1月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[pie] allow formating nubmers on pie chart (#6628)
上级
9d70c348
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
11 deletion
+18
-11
superset/assets/src/explore/controlPanels/Pie.js
superset/assets/src/explore/controlPanels/Pie.js
+7
-1
superset/assets/src/visualizations/nvd3/NVD3Vis.js
superset/assets/src/visualizations/nvd3/NVD3Vis.js
+9
-10
superset/assets/src/visualizations/nvd3/transformProps.js
superset/assets/src/visualizations/nvd3/transformProps.js
+2
-0
未找到文件。
superset/assets/src/explore/controlPanels/Pie.js
浏览文件 @
80518186
...
...
@@ -16,7 +16,7 @@ export default {
label
:
t
(
'
Chart Options
'
),
expanded
:
true
,
controlSetRows
:
[
[
'
pie_label_type
'
],
[
'
pie_label_type
'
,
'
number_format
'
],
[
'
donut
'
,
'
show_legend
'
],
[
'
show_labels
'
,
'
labels_outside
'
],
[
'
color_scheme
'
],
...
...
@@ -27,5 +27,11 @@ export default {
row_limit
:
{
default
:
25
,
},
number_format
:
{
description
:
(
t
(
'
D3 format syntax: https://github.com/d3/d3-format
'
)
+
'
'
+
t
(
'
Only applies when the "Label Type" is not set to a percentage.
'
)
),
},
},
};
superset/assets/src/visualizations/nvd3/NVD3Vis.js
浏览文件 @
80518186
...
...
@@ -6,7 +6,7 @@ import moment from 'moment';
import
PropTypes
from
'
prop-types
'
;
import
{
t
}
from
'
@superset-ui/translation
'
;
import
{
CategoricalColorNamespace
}
from
'
@superset-ui/color
'
;
import
{
getNumberFormatter
,
formatNumber
,
NumberFormats
}
from
'
@superset-ui/number-format
'
;
import
{
getNumberFormatter
,
NumberFormats
}
from
'
@superset-ui/number-format
'
;
import
{
getTimeFormatter
,
smartDateVerboseFormatter
}
from
'
@superset-ui/time-format
'
;
import
'
nvd3/build/nv.d3.min.css
'
;
...
...
@@ -127,6 +127,7 @@ const propTypes = {
'
dual_line
'
,
]),
xAxisFormat
:
PropTypes
.
string
,
numberFormat
:
PropTypes
.
string
,
xAxisLabel
:
PropTypes
.
string
,
xAxisShowMinMax
:
PropTypes
.
bool
,
xIsLogScale
:
PropTypes
.
bool
,
...
...
@@ -213,6 +214,7 @@ function nvd3Vis(element, props) {
useRichTooltip
,
vizType
,
xAxisFormat
,
numberFormat
,
xAxisLabel
,
xAxisShowMinMax
=
false
,
xField
,
...
...
@@ -264,6 +266,7 @@ function nvd3Vis(element, props) {
isTruthy
(
showBrush
)
||
(
showBrush
===
'
auto
'
&&
maxHeight
>=
MIN_HEIGHT_FOR_BRUSH
&&
xTicksLayout
!==
'
45°
'
)
);
const
numberFormatter
=
getNumberFormatter
(
numberFormat
);
switch
(
vizType
)
{
case
'
line
'
:
...
...
@@ -331,7 +334,7 @@ function nvd3Vis(element, props) {
case
'
pie
'
:
chart
=
nv
.
models
.
pieChart
();
colorKey
=
'
x
'
;
chart
.
valueFormat
(
f
ormatter
);
chart
.
valueFormat
(
numberF
ormatter
);
if
(
isDonut
)
{
chart
.
donut
(
true
);
}
...
...
@@ -341,18 +344,14 @@ function nvd3Vis(element, props) {
chart
.
labelThreshold
(
0.05
);
chart
.
cornerRadius
(
true
);
if
(
pieLabelType
!==
'
key_percent
'
&&
pieLabelType
!==
'
key_value
'
)
{
if
(
[
'
key
'
,
'
value
'
,
'
percent
'
].
indexOf
(
pieLabelType
)
>=
0
)
{
chart
.
labelType
(
pieLabelType
);
}
else
if
(
pieLabelType
===
'
key_value
'
)
{
chart
.
labelType
(
d
=>
`
${
d
.
data
.
x
}
:
${
formatNumber
(
NumberFormats
.
SI
,
d
.
data
.
y
)}
`
);
}
if
(
pieLabelType
===
'
percent
'
||
pieLabelType
===
'
key_percent
'
)
{
chart
.
labelType
(
d
=>
`
${
d
.
data
.
x
}
:
${
numberFormatter
(
d
.
data
.
y
)}
`
);
}
else
if
(
pieLabelType
===
'
key_percent
'
)
{
const
total
=
d3
.
sum
(
data
,
d
=>
d
.
y
);
chart
.
tooltip
.
valueFormatter
(
d
=>
`
${((
d
/
total
)
*
100
).
toFixed
()}
%`
);
if
(
pieLabelType
===
'
key_percent
'
)
{
chart
.
labelType
(
d
=>
`
${
d
.
data
.
x
}
:
${((
d
.
data
.
y
/
total
)
*
100
).
toFixed
()}
%`
);
}
chart
.
labelType
(
d
=>
`
${
d
.
data
.
x
}
:
${((
d
.
data
.
y
/
total
)
*
100
).
toFixed
()}
%`
);
}
// Pie chart does not need top margin
chart
.
margin
({
top
:
0
});
...
...
superset/assets/src/visualizations/nvd3/transformProps.js
浏览文件 @
80518186
...
...
@@ -45,6 +45,7 @@ export default function transformProps(chartProps) {
xAxisFormat
,
xAxisLabel
,
xAxisShowminmax
,
numberFormat
,
xLogScale
,
xTicksLayout
,
y
,
...
...
@@ -83,6 +84,7 @@ export default function transformProps(chartProps) {
leftMargin
,
lineInterpolation
,
maxBubbleSize
:
parseInt
(
maxBubbleSize
,
10
),
numberFormat
,
onBrushEnd
:
isTruthy
(
sendTimeRange
)
?
((
timeRange
)
=>
{
onAddFilter
(
'
__time_range
'
,
timeRange
,
false
,
true
);
})
:
undefined
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录