-
-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highcarts #211
Highcarts #211
Conversation
issues with all modules
Thanks for your contribution! Here are my thoughts about it:
In order to be able to merge this PR, we need to at least: remove unnecessary .map and .src.js files (1), include the remaining dependencies in chart.py and fix the JavaScript error (2). Alternatively, we could remove .map and .src.js files and all dependencies that are not needed for displaying a gauge (the original problem of issue #210, resolving points 1, 2 and 3) and think about adding more HighCharts modules later. |
I just created branch with a sketch on how we may implement opt-in for highcharts: https://github.com/zauberzeug/nicegui/tree/highcharts-extra-deps It could be used like this: solid_gauge = '''
{
chart: {
type: 'solidgauge'
},
title: null,
pane: {
center: ['50%', '85%'],
size: '140%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor: '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
},
exporting: {
enabled: false
},
tooltip: {
enabled: false
},
yAxis: {
stops: [
[0.1, '#55BF3B'],
[0.5, '#DDDF0D'],
[0.9, '#DF5353']
],
lineWidth: 0,
tickWidth: 0,
minorTickInterval: null,
tickAmount: 2,
title: {
y: -70
},
labels: {
y: 16
},
min: 0,
max: 5,
title: {
text: 'RPM'
}
},
plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
},
series: [{
name: 'RPM',
data: [1],
}]
}
'''
ui.chart(demjson3.decode(solid_gauge), ['solid-gauge']) I'm using demjson3 to transform copy&paste gauge code into dict for |
remove all unneeded files and fixed issue with loading modules.
looks great! |
nicegui/elements/chart.js
Outdated
this.chart.reflow(); | ||
}, 0); | ||
}, 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not happy with the delayed loading of the chart. We should somehow make sure that the chart is loaded as soon as the extra libs are available...
nicegui/elements/chart.py
Outdated
@@ -19,6 +92,10 @@ def __init__(self, options: Dict) -> None: | |||
""" | |||
super().__init__('chart') | |||
self._props['options'] = options | |||
urls = [f'/_nicegui/dependencies/{id}/{dependency.path.name}' | |||
for id, dependency in js_extra_dependencies.items() | |||
if any(e in dependency.path.name for e in extras)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodja Shouldn't it be
if dependency.path.name in extras
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. It could be simplified. See ee42816
nicegui/elements/chart.py
Outdated
|
||
class Chart(Element): | ||
|
||
def __init__(self, options: Dict) -> None: | ||
def __init__(self, options: Dict, extras: List[str] = []) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd mark extras
as keyword argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Ok, if I understand correctly @rodja introduced a new kind of dependencies that are served like before, but only requested if an element is configured accordingly using the
@rodja Aside from this specific PR, I'd like to discuss how we could evolve the overall concept of serving and requesting dependencies. Loading dependencies via |
I'll create a separate issue to generalize the dependency loading. |
As described in issue below there are missing files for fully functional highcharts
Issue
I added the newest highcharts version 10.3.2 with all modules. But not all modules are included in chart.py because after adding all modules there where issues with nicegui.
If you are not happy about the file structure, please comment.