Skip to content

Commit

Permalink
Add ability to change font sizes of Graph Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Dec 6, 2021
1 parent 11e4114 commit 55859e2
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions mycodo/widgets/widget_graph_synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,34 @@ def generate_page_variables(widget_unique_id, widget_options):
'name': 'Refresh (seconds)',
'phrase': 'The period of time between refreshing the widget'
},
{
'id': 'graph_font_size_em_axes',
'type': 'float',
'default_value': 1.0,
'name': 'Graph Axis Value Font Size (em)',
'phrase': 'The size of the fonts of the x/y axis values of the graph'
},
{
'id': 'graph_font_size_em_axes_title',
'type': 'float',
'default_value': 1.0,
'name': 'Graph Axis Title Font Size (em)',
'phrase': 'The size of the fonts of the x/y axis titles of the graph'
},
{
'id': 'graph_font_size_em_legend',
'type': 'float',
'default_value': 1.0,
'name': 'Graph Legend Font Size (em)',
'phrase': 'The size of the fonts on the legend of the graph'
},
{
'id': 'graph_font_size_em_title',
'type': 'float',
'default_value': 1.0,
'name': 'Graph Title Font Size (em)',
'phrase': 'The size of the fonts on the title of the graph'
},
{
'id': 'x_axis_minutes',
'type': 'integer',
Expand Down Expand Up @@ -778,16 +806,27 @@ def generate_page_variables(widget_unique_id, widget_options):
{%- endif -%}
title: {
text: "{% if widget_options['enable_title'] %}{{each_widget.name}}{% endif %}"
text: "{% if widget_options['enable_title'] %}{{each_widget.name}}{% endif %}",
style: {
fontSize:'{{widget_options['graph_font_size_em_title']}}em'
}
},
legend: {
enabled: {% if widget_options['enable_graph_legend'] %}true{% else %}false{% endif %}
enabled: {% if widget_options['enable_graph_legend'] %}true{% else %}false{% endif %},
itemStyle: {
fontSize:'{{widget_options['graph_font_size_em_legend']}}em'
}
},
xAxis: {
type: 'datetime',
ordinal: false
ordinal: false,
labels: {
style: {
fontSize:'{{widget_options['graph_font_size_em_axes']}}em'
}
}
},
yAxis: [
Expand All @@ -804,10 +843,16 @@ def generate_page_variables(widget_unique_id, widget_options):
text: "{{dict_units[each_axis_meas]['name']}}
{%- if dict_units[each_axis_meas]['unit'] != '' -%}
{{' (' + dict_units[each_axis_meas]['unit'] + ')'}}
{%- endif -%}"
{%- endif -%}",
style: {
fontSize:'{{widget_options['graph_font_size_em_axes_title']}}em'
}
},
labels: {
format: '{value}'
format: '{value}',
style: {
fontSize:'{{widget_options['graph_font_size_em_axes']}}em'
}
},
opposite: false,
id: '{{each_axis_meas}}'
Expand Down

0 comments on commit 55859e2

Please sign in to comment.