无法添加符号来指示虚线表列是可编辑的
Cannot add a symbol to indicate a dashtable column is editable
我有以下可编辑破折号数据表:
但是其他用户并不清楚最后两列的条目是否可以手动修改,如果用户愿意的话。在下面的屏幕截图中,我手动更改了红色标记的条目。
有没有办法添加下面的符号
这样很明显最后两列的条目(不是列名)是可编辑的。
我当前对该数据表的代码是:
dash_table.DataTable(
id='growth_pe',
# columns=[{'name': i, 'id': i} for i in growth_pe_table.columns],
columns = [
dict(id='company', name='Company'),
dict(id='historical_growth_rate',
name='Historical EPS Growth Rate\n (min, mean or annualized, max)'),
dict(id='historical_pe',
name='Historical PE\n (min, mean, max)'),
dict(id='annual_growth_rate',
name='Annual EPS Growth Rate\n %', type='numeric',
format=percentage, editable=True),
dict(id='pe', name='PE', editable=True)
],
感谢您的任何建议。
解决方案:
经过一些研究,现在无法将图标添加到仪表板表头中,这对我的问题来说是完美的。在我看来,目前最好的解决方案是为可编辑列着色并使用工具提示:
tooltip_header={
'historical_growth_rate': 'If (1 + EPS Growth Rate) > 0\
-> Annualized growth rate, if < 0 -> Mean value',
'annual_growth_rate': {
'value': 'This column is editable. \n\n For 12.7% \
Growth Rate, enter: 0.127\n\n'.format(
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'},
'pe': {
'value': 'This column is editable.\n\n'.format(\
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'}
},
tooltip_delay=0,
tooltip_duration=None,
tooltip={
# column: {'value': 'This column is editable.\n\n'.format(
# app.get_relative_path('/assets/images/Edit_Icon.jpg')),
# 'type': 'markdown'}
# for column in ['annual_growth_rate', 'pe']
'annual_growth_rate': {
'value': 'This column is editable. \n\n For 12.7% \
Growth Rate, enter: 0.127\n\n'.format(
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'},
'pe': {
'value': 'This column is editable.\n\n'.format(\
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'}
},
如果有人想看看它的样子,link 到 webapp:https://gunardi-dashboard.herokuapp.com
相关代码可以在这里找到:https://github.com/gunardilin/valuation_dashboard/blob/main/Dashboard.py 并查找以下关键字:growth_pe
嗯,是的,我知道您是如何从 built-in 功能中获得 SVG 的,其中 dash datatable
允许您切换 user-renaming 列。我认为不会有任何简单的(在 Python 中)方法也可以将该功能用于编辑。我在您给出的示例中没有看到样式代码,因此不确定您是如何为列着色的。但确实有 built-in 样式参数用于 color-highlighting 特定 cols/rows/cells,有条件地或明确地。
例如,您可以添加如下内容:
style_data_conditional=[{
'if': {'column_editable': True},
'backgroundColor': 'rgb(30, 0, 0)',
'textDecoration': 'underline',
'textDecorationStyle': 'dotted',
}]
其中 style_data_conditional
是将放在 dash_table.DataTable
.
括号内的属性
想到的另一个非常接近的想法是您可以使用 multi-headers 功能,并在带有列名的主要真实行下方有一个额外的 header 行,然后离开所有 non-editable 列为空白,但使用 unicode 符号表示可编辑的列。
啊!或者,实际上,这是一个更好、更简单的解决方案。条件突出显示(通过对列名称进行着色和虚线下划线)以及将显示铅笔图像的可悬停工具提示怎么样?
dash_table.DataTable(
data=df_jobs.to_dict("records"),
columns=[{"name": i, "id": i} for i in df_jobs.columns]
+ [{"name": "# of Openings", "id": "no_of_openings", "editable": True}],
style_header_conditional=[
{
"if": {"column_editable": True},
"backgroundColor": "rgb(250, 0, 0, 0.5)",
"textDecoration": "underline",
"textDecorationStyle": "dotted",
}
],
style_data_conditional=[
{"if": {"column_editable": True}, "backgroundColor": "rgb(250, 0, 0, 0.25)"}
],
# markdown_options={"html": True},
tooltip_data=[
{
"no_of_openings": {
"value": "",
"type": "markdown",
"delay": None,
"duration": None,
}
}
],
),
我放大了非常近的距离并截取了铅笔的屏幕截图,并将其作为 png 的副本放在我的 assets/images 文件夹下,显然最新版本的 dash 数据表允许将 markdown 注入到工具提示中,包括 linked 图片!您可以进一步编辑工具提示的格式,使其更小,并且我会假设许多其他微调内容,例如添加边框和移动其出现位置的坐标。这是这些文档的 link:(See the "Styling" subsection in particular).
我有以下可编辑破折号数据表:
但是其他用户并不清楚最后两列的条目是否可以手动修改,如果用户愿意的话。在下面的屏幕截图中,我手动更改了红色标记的条目。
有没有办法添加下面的符号
我当前对该数据表的代码是:
dash_table.DataTable(
id='growth_pe',
# columns=[{'name': i, 'id': i} for i in growth_pe_table.columns],
columns = [
dict(id='company', name='Company'),
dict(id='historical_growth_rate',
name='Historical EPS Growth Rate\n (min, mean or annualized, max)'),
dict(id='historical_pe',
name='Historical PE\n (min, mean, max)'),
dict(id='annual_growth_rate',
name='Annual EPS Growth Rate\n %', type='numeric',
format=percentage, editable=True),
dict(id='pe', name='PE', editable=True)
],
感谢您的任何建议。
解决方案:
经过一些研究,现在无法将图标添加到仪表板表头中,这对我的问题来说是完美的。在我看来,目前最好的解决方案是为可编辑列着色并使用工具提示:
tooltip_header={
'historical_growth_rate': 'If (1 + EPS Growth Rate) > 0\
-> Annualized growth rate, if < 0 -> Mean value',
'annual_growth_rate': {
'value': 'This column is editable. \n\n For 12.7% \
Growth Rate, enter: 0.127\n\n'.format(
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'},
'pe': {
'value': 'This column is editable.\n\n'.format(\
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'}
},
tooltip_delay=0,
tooltip_duration=None,
tooltip={
# column: {'value': 'This column is editable.\n\n'.format(
# app.get_relative_path('/assets/images/Edit_Icon.jpg')),
# 'type': 'markdown'}
# for column in ['annual_growth_rate', 'pe']
'annual_growth_rate': {
'value': 'This column is editable. \n\n For 12.7% \
Growth Rate, enter: 0.127\n\n'.format(
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'},
'pe': {
'value': 'This column is editable.\n\n'.format(\
app.get_relative_path('/assets/images/Edit_Icon.jpg')),
'type': 'markdown'}
},
如果有人想看看它的样子,link 到 webapp:https://gunardi-dashboard.herokuapp.com
相关代码可以在这里找到:https://github.com/gunardilin/valuation_dashboard/blob/main/Dashboard.py 并查找以下关键字:growth_pe
嗯,是的,我知道您是如何从 built-in 功能中获得 SVG 的,其中 dash datatable
允许您切换 user-renaming 列。我认为不会有任何简单的(在 Python 中)方法也可以将该功能用于编辑。我在您给出的示例中没有看到样式代码,因此不确定您是如何为列着色的。但确实有 built-in 样式参数用于 color-highlighting 特定 cols/rows/cells,有条件地或明确地。
例如,您可以添加如下内容:
style_data_conditional=[{
'if': {'column_editable': True},
'backgroundColor': 'rgb(30, 0, 0)',
'textDecoration': 'underline',
'textDecorationStyle': 'dotted',
}]
其中 style_data_conditional
是将放在 dash_table.DataTable
.
想到的另一个非常接近的想法是您可以使用 multi-headers 功能,并在带有列名的主要真实行下方有一个额外的 header 行,然后离开所有 non-editable 列为空白,但使用 unicode 符号表示可编辑的列。
啊!或者,实际上,这是一个更好、更简单的解决方案。条件突出显示(通过对列名称进行着色和虚线下划线)以及将显示铅笔图像的可悬停工具提示怎么样?
dash_table.DataTable(
data=df_jobs.to_dict("records"),
columns=[{"name": i, "id": i} for i in df_jobs.columns]
+ [{"name": "# of Openings", "id": "no_of_openings", "editable": True}],
style_header_conditional=[
{
"if": {"column_editable": True},
"backgroundColor": "rgb(250, 0, 0, 0.5)",
"textDecoration": "underline",
"textDecorationStyle": "dotted",
}
],
style_data_conditional=[
{"if": {"column_editable": True}, "backgroundColor": "rgb(250, 0, 0, 0.25)"}
],
# markdown_options={"html": True},
tooltip_data=[
{
"no_of_openings": {
"value": "",
"type": "markdown",
"delay": None,
"duration": None,
}
}
],
),
我放大了非常近的距离并截取了铅笔的屏幕截图,并将其作为 png 的副本放在我的 assets/images 文件夹下,显然最新版本的 dash 数据表允许将 markdown 注入到工具提示中,包括 linked 图片!您可以进一步编辑工具提示的格式,使其更小,并且我会假设许多其他微调内容,例如添加边框和移动其出现位置的坐标。这是这些文档的 link:(See the "Styling" subsection in particular).