dhxpyt.chart

1from .chart import Chart 
2from .chart_config import ChartConfig
3
4__all__ = ["Chart", "ChartConfig"]
class Chart:
  9class Chart:
 10    def __init__(self, config: ChartConfig, widget_parent: Any = None):
 11        """Initializes the chart instance."""
 12        self.chart = js.dhx.Chart.new(widget_parent, js.JSON.parse(json.dumps(config.to_dict())))
 13
 14    """ Chart API Functions """
 15
 16    def destructor(self) -> None:
 17        """Removes a chart instance and releases the occupied resources."""
 18        self.chart.destructor()
 19
 20    def each_series(self, handler: Callable[[List[Dict[str, Any]]], Any]) -> List[Any]:
 21        """Iterates over chart series."""
 22        proxy_handler = create_proxy(handler)
 23        return self.chart.eachSeries(proxy_handler)
 24
 25    def get_series(self, id: str) -> Dict[str, Any]:
 26        """Returns an object with configuration of a specified series."""
 27        return self.chart.getSeries(id)
 28
 29    def paint(self) -> None:
 30        """Repaints a chart on a page."""
 31        self.chart.paint()
 32
 33    def set_config(self, config: Dict[str, Any]) -> None:
 34        """Sets configuration of a chart."""
 35        self.chart.setConfig(js.JSON.parse(json.dumps(config)))
 36
 37    def png(self, config: Dict[str, Any] = {}) -> None:
 38        """Exports a chart to a PNG file."""
 39        self.chart.png(js.JSON.parse(json.dumps(config)))
 40
 41    def pdf(self, config: Dict[str, Any] = {}) -> None:
 42        """Exports a chart to a PDF file."""
 43        self.chart.pdf(js.JSON.parse(json.dumps(config)))
 44
 45    """ Chart Events """
 46
 47    def add_event_handler(self, event_name: str, handler: Callable) -> None:
 48        """Helper to add event handlers dynamically."""
 49        event_proxy = create_proxy(handler)
 50        self.chart.events[event_name] = event_proxy
 51
 52    def resize(self, handler: Callable[[int, int], None]) -> None:
 53        """Fires on changing the size of the chart container."""
 54        self.add_event_handler('resize', handler)
 55
 56    def serie_click(self, handler: Callable[[str, str], None]) -> None:
 57        """Fires on clicking a series."""
 58        self.add_event_handler('serieClick', handler)
 59
 60    def toggle_series(self, handler: Callable[[str, Union[Dict[str, Any], None]], None]) -> None:
 61        """Fires on toggle on/off a series in a legend."""
 62        self.add_event_handler('toggleSeries', handler)
 63
 64    """ Chart Properties """
 65
 66    @property
 67    def css(self) -> str:
 68        """Optional. Adds style classes to the chart."""
 69        return self.chart.css
 70
 71    @css.setter
 72    def css(self, value: str) -> None:
 73        self.chart.css = value
 74
 75    @property
 76    def data(self) -> List[Dict[str, Any]]:
 77        """Optional. Specifies an array of data objects to set into the chart."""
 78        return self.chart.data
 79
 80    @data.setter
 81    def data(self, value: List[Dict[str, Any]]) -> None:
 82        self.chart.data = value
 83
 84    @property
 85    def export_styles(self) -> Union[bool, List[str]]:
 86        """Optional. Defines the styles that will be sent to the export service when exporting Chart."""
 87        return self.chart.exportStyles
 88
 89    @export_styles.setter
 90    def export_styles(self, value: Union[bool, List[str]]) -> None:
 91        self.chart.exportStyles = value
 92
 93    @property
 94    def legend(self) -> Dict[str, Any]:
 95        """Optional. Defines the configuration of a chart legend."""
 96        return self.chart.legend
 97
 98    @legend.setter
 99    def legend(self, value: Dict[str, Any]) -> None:
100        self.chart.legend = value
101
102    @property
103    def max_points(self) -> int:
104        """Optional. Displays an average number of values if data set is too large."""
105        return self.chart.maxPoints
106
107    @max_points.setter
108    def max_points(self, value: int) -> None:
109        self.chart.maxPoints = value
110
111    @property
112    def scales(self) -> Dict[str, Any]:
113        """Required. Defines configuration of scales for certain chart types."""
114        return self.chart.scales
115
116    @scales.setter
117    def scales(self, value: Dict[str, Any]) -> None:
118        self.chart.scales = value
119
120    @property
121    def series(self) -> List[Dict[str, Any]]:
122        """Required. Defines configuration of chart series."""
123        return self.chart.series
124
125    @series.setter
126    def series(self, value: List[Dict[str, Any]]) -> None:
127        self.chart.series = value
128
129    @property
130    def type(self) -> str:
131        """Required. Specifies the type of a chart."""
132        return self.chart.type
133
134    @type.setter
135    def type(self, value: str) -> None:
136        self.chart.type = value
Chart( config: ChartConfig, widget_parent: Any = None)
10    def __init__(self, config: ChartConfig, widget_parent: Any = None):
11        """Initializes the chart instance."""
12        self.chart = js.dhx.Chart.new(widget_parent, js.JSON.parse(json.dumps(config.to_dict())))

Initializes the chart instance.

chart

Chart API Functions

def destructor(self) -> None:
16    def destructor(self) -> None:
17        """Removes a chart instance and releases the occupied resources."""
18        self.chart.destructor()

Removes a chart instance and releases the occupied resources.

def each_series(self, handler: Callable[[List[Dict[str, Any]]], Any]) -> List[Any]:
20    def each_series(self, handler: Callable[[List[Dict[str, Any]]], Any]) -> List[Any]:
21        """Iterates over chart series."""
22        proxy_handler = create_proxy(handler)
23        return self.chart.eachSeries(proxy_handler)

Iterates over chart series.

def get_series(self, id: str) -> Dict[str, Any]:
25    def get_series(self, id: str) -> Dict[str, Any]:
26        """Returns an object with configuration of a specified series."""
27        return self.chart.getSeries(id)

Returns an object with configuration of a specified series.

def paint(self) -> None:
29    def paint(self) -> None:
30        """Repaints a chart on a page."""
31        self.chart.paint()

Repaints a chart on a page.

def set_config(self, config: Dict[str, Any]) -> None:
33    def set_config(self, config: Dict[str, Any]) -> None:
34        """Sets configuration of a chart."""
35        self.chart.setConfig(js.JSON.parse(json.dumps(config)))

Sets configuration of a chart.

def png(self, config: Dict[str, Any] = {}) -> None:
37    def png(self, config: Dict[str, Any] = {}) -> None:
38        """Exports a chart to a PNG file."""
39        self.chart.png(js.JSON.parse(json.dumps(config)))

Exports a chart to a PNG file.

def pdf(self, config: Dict[str, Any] = {}) -> None:
41    def pdf(self, config: Dict[str, Any] = {}) -> None:
42        """Exports a chart to a PDF file."""
43        self.chart.pdf(js.JSON.parse(json.dumps(config)))

Exports a chart to a PDF file.

def add_event_handler(self, event_name: str, handler: Callable) -> None:
47    def add_event_handler(self, event_name: str, handler: Callable) -> None:
48        """Helper to add event handlers dynamically."""
49        event_proxy = create_proxy(handler)
50        self.chart.events[event_name] = event_proxy

Helper to add event handlers dynamically.

def resize(self, handler: Callable[[int, int], NoneType]) -> None:
52    def resize(self, handler: Callable[[int, int], None]) -> None:
53        """Fires on changing the size of the chart container."""
54        self.add_event_handler('resize', handler)

Fires on changing the size of the chart container.

def serie_click(self, handler: Callable[[str, str], NoneType]) -> None:
56    def serie_click(self, handler: Callable[[str, str], None]) -> None:
57        """Fires on clicking a series."""
58        self.add_event_handler('serieClick', handler)

Fires on clicking a series.

def toggle_series( self, handler: Callable[[str, Optional[Dict[str, Any]]], NoneType]) -> None:
60    def toggle_series(self, handler: Callable[[str, Union[Dict[str, Any], None]], None]) -> None:
61        """Fires on toggle on/off a series in a legend."""
62        self.add_event_handler('toggleSeries', handler)

Fires on toggle on/off a series in a legend.

css: str
66    @property
67    def css(self) -> str:
68        """Optional. Adds style classes to the chart."""
69        return self.chart.css

Optional. Adds style classes to the chart.

data: List[Dict[str, Any]]
75    @property
76    def data(self) -> List[Dict[str, Any]]:
77        """Optional. Specifies an array of data objects to set into the chart."""
78        return self.chart.data

Optional. Specifies an array of data objects to set into the chart.

export_styles: Union[bool, List[str]]
84    @property
85    def export_styles(self) -> Union[bool, List[str]]:
86        """Optional. Defines the styles that will be sent to the export service when exporting Chart."""
87        return self.chart.exportStyles

Optional. Defines the styles that will be sent to the export service when exporting Chart.

legend: Dict[str, Any]
93    @property
94    def legend(self) -> Dict[str, Any]:
95        """Optional. Defines the configuration of a chart legend."""
96        return self.chart.legend

Optional. Defines the configuration of a chart legend.

max_points: int
102    @property
103    def max_points(self) -> int:
104        """Optional. Displays an average number of values if data set is too large."""
105        return self.chart.maxPoints

Optional. Displays an average number of values if data set is too large.

scales: Dict[str, Any]
111    @property
112    def scales(self) -> Dict[str, Any]:
113        """Required. Defines configuration of scales for certain chart types."""
114        return self.chart.scales

Required. Defines configuration of scales for certain chart types.

series: List[Dict[str, Any]]
120    @property
121    def series(self) -> List[Dict[str, Any]]:
122        """Required. Defines configuration of chart series."""
123        return self.chart.series

Required. Defines configuration of chart series.

type: str
129    @property
130    def type(self) -> str:
131        """Required. Specifies the type of a chart."""
132        return self.chart.type

Required. Specifies the type of a chart.

class ChartConfig(dhxpyt.chart.chart_config.ControlConfig):
 8class ChartConfig(ControlConfig):
 9    """Configuration class for Chart."""
10    def __init__(self,
11                 type: str,
12                 series: List[Dict[str, Any]],
13                 scales: Dict[str, Any],
14                 data: List[Dict[str, Any]] = None,
15                 legend: Dict[str, Any] = None,
16                 css: str = None,
17                 max_points: int = None,
18                 export_styles: Union[bool, List[str]] = False):
19        self.type = type
20        self.series = series
21        self.scales = scales
22        self.data = data
23        self.legend = legend
24        self.css = css
25        self.max_points = max_points
26        self.export_styles = export_styles

Configuration class for Chart.

ChartConfig( type: str, series: List[Dict[str, Any]], scales: Dict[str, Any], data: List[Dict[str, Any]] = None, legend: Dict[str, Any] = None, css: str = None, max_points: int = None, export_styles: Union[bool, List[str]] = False)
10    def __init__(self,
11                 type: str,
12                 series: List[Dict[str, Any]],
13                 scales: Dict[str, Any],
14                 data: List[Dict[str, Any]] = None,
15                 legend: Dict[str, Any] = None,
16                 css: str = None,
17                 max_points: int = None,
18                 export_styles: Union[bool, List[str]] = False):
19        self.type = type
20        self.series = series
21        self.scales = scales
22        self.data = data
23        self.legend = legend
24        self.css = css
25        self.max_points = max_points
26        self.export_styles = export_styles
type
series
scales
data
legend
css
max_points
export_styles