Explorar o código

Merge pull request #2122 from zauberzeug/highcharts

Provide minimal highcharts docs and warning
Falko Schindler hai 1 ano
pai
achega
f40963549e
Modificáronse 1 ficheiros con 18 adicións e 3 borrados
  1. 18 3
      nicegui/elements/highchart.py

+ 18 - 3
nicegui/elements/highchart.py

@@ -1,10 +1,25 @@
 from .. import optional_features
+from ..element import Element
+from ..logging import log
+from .markdown import Markdown
 
 try:
     from nicegui_highcharts import highchart
     optional_features.register('highcharts')
     __all__ = ['highchart']
 except ImportError:
-    class highchart:  # type: ignore
-        def __init__(self, *args, **kwargs) -> None:
-            raise NotImplementedError('Highcharts is not installed. Please run `pip install nicegui[highcharts]`.')
+    class highchart(Element):  # type: ignore
+        def __init__(self, *args, **kwargs) -> None:  # pylint: disable=unused-argument
+            """Highcharts chart
+
+            An element to create a chart using `Highcharts <https://www.highcharts.com/>`_.
+            Updates can be pushed to the chart by changing the `options` property.
+            After data has changed, call the `update` method to refresh the chart.
+
+            Due to Highcharts' restrictive license, this element is not part of the standard NiceGUI package.
+            It is maintained in a `separate repository <https://github.com/zauberzeug/nicegui-highcharts/>`_
+            and can be installed with `pip install nicegui[highcharts]`.
+            """
+            super().__init__()
+            Markdown('Highcharts is not installed. Please run `pip install nicegui[highcharts]`.')
+            log.warning('Highcharts is not installed. Please run "pip install nicegui[highcharts]".')