Creates a JavaScript chart using the "HighCharts" library.
(
self,
chart_name=None,
title=None,
subtitle=None,
style=None,
data_name=None,
unit=None,
zero=False,
libs=True,
labels=True,
legend=True,
)
| 12892 | ) |
| 12893 | |
| 12894 | def __create_highchart( |
| 12895 | self, |
| 12896 | chart_name=None, |
| 12897 | title=None, |
| 12898 | subtitle=None, |
| 12899 | style=None, |
| 12900 | data_name=None, |
| 12901 | unit=None, |
| 12902 | zero=False, |
| 12903 | libs=True, |
| 12904 | labels=True, |
| 12905 | legend=True, |
| 12906 | ): |
| 12907 | """Creates a JavaScript chart using the "HighCharts" library.""" |
| 12908 | if not chart_name: |
| 12909 | chart_name = "default" |
| 12910 | if not title: |
| 12911 | title = "" |
| 12912 | if not subtitle: |
| 12913 | subtitle = "" |
| 12914 | if not style: |
| 12915 | style = "pie" |
| 12916 | if not data_name: |
| 12917 | data_name = "Series 1" |
| 12918 | if not unit: |
| 12919 | unit = "Values" |
| 12920 | if labels: |
| 12921 | labels = "true" |
| 12922 | else: |
| 12923 | labels = "false" |
| 12924 | if legend: |
| 12925 | legend = "true" |
| 12926 | else: |
| 12927 | legend = "false" |
| 12928 | title = title.replace("'", "\\'") |
| 12929 | subtitle = subtitle.replace("'", "\\'") |
| 12930 | unit = unit.replace("'", "\\'") |
| 12931 | self._chart_count += 1 |
| 12932 | # If chart_libs format is changed, also change: save_presentation() |
| 12933 | chart_libs = """ |
| 12934 | <script src="%s"></script> |
| 12935 | <script src="%s"></script> |
| 12936 | <script src="%s"></script> |
| 12937 | <script src="%s"></script> |
| 12938 | """ % ( |
| 12939 | constants.HighCharts.HC_JS, |
| 12940 | constants.HighCharts.EXPORTING_JS, |
| 12941 | constants.HighCharts.EXPORT_DATA_JS, |
| 12942 | constants.HighCharts.ACCESSIBILITY_JS, |
| 12943 | ) |
| 12944 | if not libs: |
| 12945 | chart_libs = "" |
| 12946 | chart_css = """ |
| 12947 | <style> |
| 12948 | .highcharts-figure, .highcharts-data-table table { |
| 12949 | min-width: 320px; |
| 12950 | max-width: 660px; |
| 12951 | margin: 1em auto; |
no outgoing calls
no test coverage detected