From cc94d029a103dd1c6d83e0f219b8c54dbf1af2b4 Mon Sep 17 00:00:00 2001 From: stewit <> Date: Sun, 5 Jul 2026 21:40:29 +0200 Subject: [PATCH 1/7] add color, locale, plotly theme, timstamp ticks --- docs/first_steps.html | 2 +- docs/genindex.html | 26 ++++++- docs/index.html | 84 ++++++++++++++++++++++- docs/objects.inv | Bin 445 -> 483 bytes docs/py-modindex.html | 2 +- docs/search.html | 2 +- docs/searchindex.js | 2 +- pyproject.toml | 5 +- sphinx/source/conf.py | 30 ++++---- src/hdhelpers/helpers/__init__.py | 14 +++- src/hdhelpers/helpers/color.py | 51 ++++++++++++++ src/hdhelpers/helpers/locale.py | 26 +++++++ src/hdhelpers/helpers/plotly_theme.py | 62 +++++++++++++++++ src/hdhelpers/helpers/timestamp_ticks.py | 44 ++++++++++++ tests/helpers/test_color_handling.py | 7 ++ tests/helpers/test_locale_handling.py | 18 +++++ 16 files changed, 352 insertions(+), 23 deletions(-) create mode 100644 src/hdhelpers/helpers/color.py create mode 100644 src/hdhelpers/helpers/locale.py create mode 100644 src/hdhelpers/helpers/plotly_theme.py create mode 100644 src/hdhelpers/helpers/timestamp_ticks.py create mode 100644 tests/helpers/test_color_handling.py create mode 100644 tests/helpers/test_locale_handling.py diff --git a/docs/first_steps.html b/docs/first_steps.html index f0b36ca..58fe4d5 100644 --- a/docs/first_steps.html +++ b/docs/first_steps.html @@ -193,7 +193,7 @@

Navigation

diff --git a/docs/genindex.html b/docs/genindex.html index 145b0e1..203c4fe 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -43,12 +43,16 @@

Index

| H | I | M + | R + | S

G

+

R

+ + +
+ +

S

+ + + +
+
@@ -173,7 +197,7 @@

Navigation

diff --git a/docs/index.html b/docs/index.html index ad4989a..47525bd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -596,6 +596,25 @@

Functions

helpers

Collection of useful functions to ease some operations in hetida designer code.

+
+
+hdhelpers.helpers.get_locale(explicit_locale=None)
+

Extract (Plotly) locale

+

Infers Plotly locale from plot target settings or returns explicit provided +locale.

+
+
Parameters:
+

explicit_locale (str | None) – Defaults to None. Locale string like “de”, “en-US” or similar. Will be returned instead of what is inferred from plot_target_settings if provided

+
+
Returns:
+

Extracted locale (like “de_DE”)

+
+
Return type:
+

str | None

+
+
+
+
hdhelpers.helpers.modify_timezone(object_to_convert, to_timezone=None, column_names=None, convert_index=True)
@@ -632,6 +651,65 @@

Functions +
+hdhelpers.helpers.resolve_color(color_str)
+

Resolves Fuseki Colors and returns resulting color string

+

Non-fuseki (color) strings are returned just as they are.

+
+
Parameters:
+

color_str (str) – Color string like “#ea1255”, “orange” or “ki.shade” (Fuseki color)

+
+
Returns:
+

Returns the resolved color string.

+
+
Return type:
+

str

+
+
+

Code example:

+

+ +
+
+hdhelpers.helpers.set_agnostic_theme(fig)
+

Set Plotly template of figure to the theme_agnostic_template

+

This Plotly template should yield good results for both light and dark themed +backgrounds.

+
+
Parameters:
+

fig (plotly Figure object) – Plotly figure object whose template will be set.

+
+
Returns:
+

Returns None, since the figure object is modified in place

+
+
Return type:
+

None

+
+
+
+ +
+
+hdhelpers.helpers.set_dt_ticks(fig)
+

Set x datetime tick labels to language agnostic format

+

Sets the x axes tick format of the Plotly Figure to some isoformat inspired +timestamp format, adequately for multiple zoom levels.

+

Infers Plotly locale from plot target settings or returns explicit provided +locale.

+
+
Parameters:
+

fig (plotly Figure object) – Plotly figure object whose x axes will be modified.

+
+
Returns:
+

Returns None, since the figure object is modified in place

+
+
Return type:
+

None

+
+
+
+

exceptions

@@ -715,7 +793,11 @@

Table of Contents

  • helpers
  • exceptions
      @@ -773,7 +855,7 @@

      Navigation

    diff --git a/docs/objects.inv b/docs/objects.inv index 1b7f692a1ab8824b2347d12995a61d1dbcf00314..6bc4d94758263850474802f32e3662b4a81198de 100644 GIT binary patch delta 352 zcmV-m0iXW81LFgbjDJdeKxFJmY~k3!GpQQB9_Lk371YFK<>=0wI}b-zQh}+#V+Kb7 zHECy&)$O)&vN6COn6?s*nWDGIldj;)*?-lz2Xy8Dxp2n$wJ?UR zd1)Pz7C9-XAjUyb=w5u_Qnmu(a=e(ui=Lo<(^6w?c$-^Z!RoTTLj@cg9|pD*Yd}6M zP20jn@$s#HHsCeLP@2FWxQQ~s&I8XDd5cf<8b*G09kED*pSRFadMH_K{ zO4q;@vd|twL0N(t8Is&eCs?{+Gr7-Y&z-<}At}N3ENavigation
  • diff --git a/docs/search.html b/docs/search.html index 512e52a..46580a9 100644 --- a/docs/search.html +++ b/docs/search.html @@ -94,7 +94,7 @@

    Navigation

    diff --git a/docs/searchindex.js b/docs/searchindex.js index 11f5f46..a61b8e1 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","modify_timezone"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"05t13":1,"06t13":1,"5s":0,"A":1,"All":0,"As":[],"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"Then":[],"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"add_config_set":[],"adequ":1,"adit":1,"adjust":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"autoexpand":[],"avail":1,"awar":0,"axes_label_color":[],"axi":0,"b":[],"background":[],"background_color":0,"bar":[],"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"by_metr":1,"c":1,"call":[],"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"circl":[],"class":1,"cm":0,"code":[0,1],"collect":1,"color":0,"colorway":[],"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correct":[],"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"datetime_tick_format":[],"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"deprec":[],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"displaylogo":[],"displaymodebar":[],"doe":0,"e":1,"eas":1,"edg":0,"edit":0,"empti":1,"enabl":1,"end":[0,1],"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"ever":[],"exampl":[0,1],"exclus":1,"expect":1,"explan":[],"explicit":0,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fals":[],"fig":0,"figur":0,"find":[],"first":1,"fit":[],"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":0,"goal":0,"graph_object":0,"grid":[],"grid_color":[],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"hide_legend":[],"hide_x_titl":[],"higher":[],"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"info":1,"info_color":0,"inform":0,"input":0,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":0,"keep":0,"key":1,"kwarg":1,"l":[],"label":0,"last":[],"layout":[],"leav":[],"legend":[],"let":[0,1],"level":0,"like":[0,1],"limit":0,"line":0,"line_color":[],"list":1,"local":[],"logo":[],"look":0,"m":1,"magnitud":0,"main":0,"make":0,"margin":[],"marker":0,"marker_symbol":[],"match":[],"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"minim":[],"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"modifyng":[],"mtsf":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"necessari":[],"next":[],"none":1,"normal":[],"note":[0,1],"now":[],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"order":0,"otherwis":0,"output":1,"packag":1,"pad":[],"panda":1,"paper":[],"paper_bgcolor":[],"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":[],"platform":1,"pleas":1,"plot":1,"plot_bgcolor":[],"plot_target_local":[],"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"prioriti":[],"properti":0,"provid":[0,1],"provis":0,"purpos":0,"pytz":1,"queri":1,"r":[],"rais":1,"rang":0,"rare":[],"re":1,"reason":0,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"remov":[],"remove_plotly_bar":[],"remove_plotly_icon":[],"repres":0,"request":[0,1],"result":1,"retriev":[0,1],"return":[0,1],"rgba":[],"ruhr":1,"run":[],"s":[0,1],"said":[],"say":0,"scatter":0,"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"showlegend":[],"simple_whit":[],"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"size":[],"soon":[],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"t":[],"tbd":1,"temp":1,"temperatur":1,"templat":[],"test":1,"tickformat":[],"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"title_standoff":[],"title_text":[],"to_datetim":1,"to_timezon":1,"toggleabl":1,"total_second":1,"trace":[],"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"unless":[],"updat":[],"update_layout":0,"update_x_axes_tickformat":[],"update_xax":0,"use":1,"use_default_standoff":[],"use_minimum_margin":[],"use_muplot_axes_color":[],"use_muplot_grid":[],"use_muplot_line_and_mark":[],"use_platform_background":[],"use_platform_colorway":[],"use_platform_default":[],"use_simple_white_templ":[],"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"visibl":[],"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"width":[],"will":0,"without":[],"write":1,"wwe":[],"x":0,"xax":[],"y":0,"yax":[],"yaxis_titl":0,"zone":1,"\u00b5plot":[]},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"except":1,"explan":0,"first":0,"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file +Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"],[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"05t13":1,"06t13":1,"5s":0,"A":1,"All":0,"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"avail":1,"awar":0,"axe":1,"axi":0,"background":1,"background_color":0,"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"by_metr":1,"c":1,"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"dark":1,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"de":1,"de_d":1,"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"doe":0,"e":1,"ea1255":1,"eas":1,"edg":0,"edit":0,"empti":1,"en":1,"enabl":1,"end":[0,1],"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"exampl":[0,1],"exclus":1,"expect":1,"explicit":[0,1],"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fig":[0,1],"figur":[0,1],"first":1,"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_local":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":0,"goal":0,"good":1,"graph_object":0,"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"infer":1,"info":1,"info_color":0,"inform":0,"input":0,"insoformat":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":[0,1],"keep":0,"key":1,"ki":1,"kwarg":1,"label":[0,1],"languag":1,"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"list":1,"local":1,"look":0,"m":1,"magnitud":0,"main":0,"make":0,"marker":0,"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"miss":0,"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"non":1,"none":1,"note":[0,1],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"orang":1,"order":0,"otherwis":0,"output":1,"packag":1,"panda":1,"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":1,"platform":1,"pleas":1,"plot":1,"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"properti":0,"provid":[0,1],"provis":0,"purpos":0,"pytz":1,"queri":1,"rais":1,"rang":0,"re":1,"reason":0,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"repres":0,"request":[0,1],"resolv":1,"resolve_color":1,"result":1,"retriev":[0,1],"return":[0,1],"ruhr":1,"s":[0,1],"say":0,"scatter":0,"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"set_agnostic_them":1,"set_dt_tick":1,"set_language_agnostic_datetime_tick":[],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"similar":1,"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"target":1,"tbd":1,"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":1,"tick":1,"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"to_datetim":1,"to_timezon":1,"toggleabl":1,"total_second":1,"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"update_layout":0,"update_xax":0,"us":1,"use":1,"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"whose":1,"will":[0,1],"write":1,"x":[0,1],"y":0,"yaxis_titl":0,"yield":1,"zone":1,"zoom":1},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"except":1,"explan":0,"first":0,"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 420c0ce..0b5d536 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,6 @@ maintainers = [ {name = "hetida", email = "hetida@fuseki.com"}, {name = "Steffen Wittkamp", email = "swittkamp@fuseki.com"}, {name = "Jenny Kupzig", email = "jkupzig@fuseki.com"}, - {name = "Christoph Dingel", email = "cdingel@fuseki.com"} ] requires-python = ">=3.12" @@ -107,3 +106,7 @@ dev = [ [[tool.mypy.overrides]] module = ["glom"] ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["plotly", "plotly.*"] +ignore_missing_imports = true \ No newline at end of file diff --git a/sphinx/source/conf.py b/sphinx/source/conf.py index f749b08..f573e6a 100644 --- a/sphinx/source/conf.py +++ b/sphinx/source/conf.py @@ -6,48 +6,48 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'hdhelpers' -copyright = '2026, Steffen Wittkamp, Jenny Kupzig, Christoph Dingel' -author = 'Steffen Wittkamp, Jenny Kupzig, Christoph Dingel' -release = '-' +project = "hdhelpers" +copyright = "2026, Steffen Wittkamp, Jenny Kupzig" +author = "Steffen Wittkamp, Jenny Kupzig" +release = "-" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [] -templates_path = ['_templates'] +templates_path = ["_templates"] exclude_patterns = [] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'classic' #'sphinxdoc' -html_static_path = ['_static'] +html_theme = "classic" #'sphinxdoc' +html_static_path = ["_static"] templates_path = ["_templates"] html_css_files = [ - 'stylesheet.css', + "stylesheet.css", ] extensions = [ - 'sphinx.ext.autodoc', # docstrings to documentation - 'sphinx.ext.napoleon', # enables Sphinx to parse both NumPy and Google style docstrings - 'sphinx.ext.doctest' # enabled embedding and testing Python code examples in documentation + "sphinx.ext.autodoc", # docstrings to documentation + "sphinx.ext.napoleon", # enables Sphinx to parse both NumPy and Google style docstrings + "sphinx.ext.doctest", # enabled embedding and testing Python code examples in documentation ] autosummary_generate = False autodoc_typehints = "description" -toc_object_entries_show_parents= 'hide' # hide class name in Table of Contents +toc_object_entries_show_parents = "hide" # hide class name in Table of Contents # -- setting hdhelpers on path to be importable -- import sys from pathlib import Path -sys.path.insert(0, str(Path('..', 'src','hdhelpers').resolve())) +sys.path.insert(0, str(Path("..", "src", "hdhelpers").resolve())) -doctest_global_setup = ''' +doctest_global_setup = """ try: import pandas as pd from hdhelpers import * @@ -59,4 +59,4 @@ multitsframe = pd.DataFrame() except ImportError: pd = None -''' +""" diff --git a/src/hdhelpers/helpers/__init__.py b/src/hdhelpers/helpers/__init__.py index e5233a9..06bbff3 100644 --- a/src/hdhelpers/helpers/__init__.py +++ b/src/hdhelpers/helpers/__init__.py @@ -1,5 +1,17 @@ """Collection of useful functions to ease some operations in hetida designer code.""" +from .color import resolve_color +from .locale import get_locale +from .plotly_theme import set_agnostic_theme, theme_agnostic_template +from .timestamp_ticks import TICKFORMATSTOPS, set_dt_ticks from .timezone_handling import modify_timezone -__all__ = ["modify_timezone"] +__all__ = [ + "modify_timezone", + "resolve_color", + "get_locale", + "TICKFORMATSTOPS", + "set_dt_ticks", + "theme_agnostic_template", + "set_agnostic_theme", +] diff --git a/src/hdhelpers/helpers/color.py b/src/hdhelpers/helpers/color.py new file mode 100644 index 0000000..14c7bba --- /dev/null +++ b/src/hdhelpers/helpers/color.py @@ -0,0 +1,51 @@ +FUSEKI_COLORS = { + "ki.vision": "#eb7c45", # orange + "ki.change": "#2fae53", # green + "ki.contrast": "#232326", # black + "ki.insight": "#e5cf64", # yellow / gold + "ki.tech": "#80b0ec", # blue + "ki.shade": "#8c8c98", # gray + "ki.vision.bright": "#ffb058", # light orange + "ki.change.bright": "#89ce6e", # light green + "ki.light": "#f8f8f8", # off-white / light gray + "ki.energy": "#eb6962", # red / coral + "ki.science": "#bd7abb", # purple + # more telling color names: + "ki.orange": "#eb7c45", # orange + "ki.green": "#2fae53", # green + "ki.black": "#232326", # black + "ki.yellow": "#e5cf64", # yellow / gold + "ki.blue": "#80b0ec", # blue + "ki.gray": "#8c8c98", # gray + "ki.lightyellow": "#ffb058", # light orange + "ki.lightorange": "#ffb058", # light orange + "ki.lightgreen": "#89ce6e", # light green + "ki.white": "#f8f8f8", # off-white / light gray + "ki.red": "#eb6962", # red / coral + "ki.purple": "#bd7abb", # purple +} + + +def resolve_color(color_str: str) -> str: + """Resolves Fuseki Colors and returns resulting color string + + Non-fuseki (color) strings are returned just as they are. + + Args: + color_str (str): Color string like "#ea1255", "orange" or "ki.shade" (Fuseki color) + + Returns: + str: + Returns the resolved color string. + + + Code example: + + .. doctest: + + >>> resolve_color("red") + red + >>> resulve_color("ki.energy") + #eb6962 + """ + return FUSEKI_COLORS.get(color_str, color_str) diff --git a/src/hdhelpers/helpers/locale.py b/src/hdhelpers/helpers/locale.py new file mode 100644 index 0000000..efab657 --- /dev/null +++ b/src/hdhelpers/helpers/locale.py @@ -0,0 +1,26 @@ +import hdhelpers + + +def get_locale(explicit_locale: str | None = None) -> str | None: + """Extract (Plotly) locale + + Infers Plotly locale from plot target settings or returns explicit provided + locale. + + Args: + explicit_locale (str | None): Defaults to None. Locale string like "de", "en-US" or similar. Will be returned instead of what is inferred from plot_target_settings if provided + + Returns: + str | None: + Extracted locale (like "de_DE") + + """ + if explicit_locale: + return explicit_locale.replace("_", "-") + + plot_target_settings = hdhelpers.plot_target_settings.get_plot_target_settings() + + if plot_target_settings.plot_target_locale is not None: + return plot_target_settings.plot_target_locale.replace("_", "-") + + return None diff --git a/src/hdhelpers/helpers/plotly_theme.py b/src/hdhelpers/helpers/plotly_theme.py new file mode 100644 index 0000000..c9e6ec0 --- /dev/null +++ b/src/hdhelpers/helpers/plotly_theme.py @@ -0,0 +1,62 @@ +import plotly.graph_objects as go +import plotly.io as pio + +NEUTRAL = "rgba(128,128,128,0.4)" +NEUTRAL_GRID = "rgba(128,128,128,0.25)" +NEUTRAL_TEXT = "rgba(128,128,128,0.9)" + +theme_agnostic_template = go.layout.Template( + layout=go.Layout( + paper_bgcolor="rgba(0, 0, 0, 0)", + plot_bgcolor="rgba(128, 128, 128, 0)", + # plot_bg_color not 0,0,0,0 because zoom highlighting then does not work properly! + # Must be >=128 to actuall work in light mode! + font=dict(color=NEUTRAL_TEXT, family="Inter, Helvetica, sans-serif", size=12), + xaxis=dict( + showgrid=True, + gridcolor=NEUTRAL_GRID, + zerolinecolor=NEUTRAL, + linecolor=NEUTRAL, + tickfont=dict(color=NEUTRAL_TEXT), + ), + yaxis=dict( + showgrid=True, + gridcolor=NEUTRAL_GRID, + zerolinecolor=NEUTRAL, + linecolor=NEUTRAL, + tickfont=dict(color=NEUTRAL_TEXT), + ), + hoverlabel=dict( + bgcolor="rgba(128,128,128,0.85)", + bordercolor="rgba(0,0,0,0.08)", + font=dict(color="#fff", size=12, family="Inter, Helvetica, sans-serif"), + namelength=0, + ), + modebar=dict( + bgcolor="rgba(0,0,0,0)", + color=NEUTRAL_TEXT, + activecolor="rgba(128,128,128,1)", + ), + ) +) + +pio.templates["theme_agnostic"] = theme_agnostic_template + +pio.templates.default = "theme_agnostic" + + +def set_agnostic_theme(fig: go.Figure) -> None: + """Set Plotly template of figure to the theme_agnostic_template + + This Plotly template should yield good results for both light and dark themed + backgrounds. + + Args: + fig (plotly Figure object): Plotly figure object whose template will be set. + + Returns: + None: + Returns None, since the figure object is modified in place + + """ + fig.update_layout(template=theme_agnostic_template) diff --git a/src/hdhelpers/helpers/timestamp_ticks.py b/src/hdhelpers/helpers/timestamp_ticks.py new file mode 100644 index 0000000..a3ac28a --- /dev/null +++ b/src/hdhelpers/helpers/timestamp_ticks.py @@ -0,0 +1,44 @@ +"""Language agnostic multi-zoom-level x axis time range ticks for plotly + +Usage: + + fig.update_xaxes( + tickformatstops=TICKFORMATSTOPS + ) +""" + +import plotly.graph_objects as go + +TICKFORMATSTOPS = [ + # language agnostic, isoformat inspired, plotl x axis timestamp formatting + # defined for multiple zoom levels + # always showing a tick with the current day somewhere for reference + dict(dtickrange=[None, 1000], value="%H:%M:%S.%L\n%Y-%m-%d"), + dict(dtickrange=[1000, 60000], value="%H:%M:%S\n%Y-%m-%d"), + dict(dtickrange=[60000, 3600000], value="%H:%M\n%Y-%m-%d"), + dict(dtickrange=[3600000, 86400000], value="%H:%M\n%Y-%m-%d"), + dict(dtickrange=[86400000, 604800000], value="%m-%d"), + dict(dtickrange=[604800000, "M1"], value="%m-%d"), + dict(dtickrange=["M1", "M12"], value="%Y-%m"), + dict(dtickrange=["M12", None], value="%Y"), +] + + +def set_dt_ticks(fig: go.Figure) -> None: + """Set x datetime tick labels to language agnostic format + + Sets the x axes tick format of the Plotly Figure to some isoformat inspired + timestamp format, adequately for multiple zoom levels. + + Infers Plotly locale from plot target settings or returns explicit provided + locale. + + Args: + fig (plotly Figure object): Plotly figure object whose x axes will be modified. + + Returns: + None: + Returns None, since the figure object is modified in place + + """ + fig.update_xaxes(tickformatstops=TICKFORMATSTOPS) diff --git a/tests/helpers/test_color_handling.py b/tests/helpers/test_color_handling.py new file mode 100644 index 0000000..7736f77 --- /dev/null +++ b/tests/helpers/test_color_handling.py @@ -0,0 +1,7 @@ +from hdhelpers.helpers import resolve_color + + +def test_resolve_color(): + assert resolve_color("ki.vision.bright") == "#ffb058" + assert resolve_color("red") == "red" + assert resolve_color("#feb0e8") == "#feb0e8" diff --git a/tests/helpers/test_locale_handling.py b/tests/helpers/test_locale_handling.py new file mode 100644 index 0000000..1f3c7ab --- /dev/null +++ b/tests/helpers/test_locale_handling.py @@ -0,0 +1,18 @@ +from unittest.mock import MagicMock, patch + +from hdhelpers.helpers import get_locale +from hdhelpers.plot_target_settings import PlotTargetSettings + + +def test_get_locale(): + assert get_locale("de") == "de" + assert get_locale("de_DE") == "de-DE" + + plot_target_settings_mock = MagicMock( + return_value=PlotTargetSettings(plot_target_locale="en_US") + ) + with patch( + "hdhelpers.plot_target_settings.get_plot_target_settings", plot_target_settings_mock + ): + assert get_locale() == "en-US" + assert get_locale("de") == "de" From 7d265b158d7084e16dd17d4ef473eb3d99d8d454 Mon Sep 17 00:00:00 2001 From: jenny kupzigSCRIPT Date: Mon, 6 Jul 2026 06:49:01 +0000 Subject: [PATCH 2/7] fix doctest in resolve_colors --- src/hdhelpers/helpers/color.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hdhelpers/helpers/color.py b/src/hdhelpers/helpers/color.py index 14c7bba..b3294e8 100644 --- a/src/hdhelpers/helpers/color.py +++ b/src/hdhelpers/helpers/color.py @@ -41,11 +41,11 @@ def resolve_color(color_str: str) -> str: Code example: - .. doctest: + .. doctest:: >>> resolve_color("red") - red - >>> resulve_color("ki.energy") - #eb6962 + 'red' + >>> resolve_color("ki.energy") + '#eb6962' """ return FUSEKI_COLORS.get(color_str, color_str) From e817d4b9686de40ff30cfb6cc1456eb604a39563 Mon Sep 17 00:00:00 2001 From: stewit <> Date: Mon, 6 Jul 2026 15:04:16 +0200 Subject: [PATCH 3/7] add doctest and make functions importable from hdhelpers directly --- docs/index.html | 28 +++++++++++++++++++++++- docs/searchindex.js | 2 +- src/hdhelpers/__init__.py | 11 +++++++++- src/hdhelpers/helpers/locale.py | 10 +++++++++ src/hdhelpers/helpers/plotly_theme.py | 10 ++++++++- src/hdhelpers/helpers/timestamp_ticks.py | 8 +++++++ 6 files changed, 65 insertions(+), 4 deletions(-) diff --git a/docs/index.html b/docs/index.html index 47525bd..9f1fa2b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -613,6 +613,14 @@

    Functions

    str | None

    +

    Code example:

    +
    >>> get_locale("de_DE")         # returns "de-DE"
    +'de-DE'
    +
    +>>> print(get_locale())         # returns locale from plot target settings of execution or None
    +None
    +
    +
    @@ -668,12 +676,18 @@

    Functions
    >>> resolve_color("red")
    +'red'
    +>>> resolve_color("ki.energy")
    +'#eb6962'
    +
    +

    hdhelpers.helpers.set_agnostic_theme(fig)
    -

    Set Plotly template of figure to the theme_agnostic_template

    +

    Set Plotly template of figure to a theme agnostic template

    This Plotly template should yield good results for both light and dark themed backgrounds.

    @@ -687,6 +701,12 @@

    Functions

    None

    +

    Code example:

    +
    >>> import plotly.graph_objects as go
    +>>> fig = go.Figure(data=go.Scatter(x=[1, 2, 3], y=[1, 4, 9]))
    +>>> set_agnostic_theme(fig)
    +
    +
    @@ -708,6 +728,12 @@

    Functions

    None

    +

    Code example:

    +
    >>> import plotly.graph_objects as go
    +>>> fig = go.Figure(data=go.Scatter(x=["2024-01-01", "2024-01-02"], y=[1, 4]))
    +>>> set_dt_ticks(fig)
    +
    +
    diff --git a/docs/searchindex.js b/docs/searchindex.js index a61b8e1..779bb94 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"],[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"05t13":1,"06t13":1,"5s":0,"A":1,"All":0,"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"avail":1,"awar":0,"axe":1,"axi":0,"background":1,"background_color":0,"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"by_metr":1,"c":1,"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"dark":1,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"de":1,"de_d":1,"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"doe":0,"e":1,"ea1255":1,"eas":1,"edg":0,"edit":0,"empti":1,"en":1,"enabl":1,"end":[0,1],"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"exampl":[0,1],"exclus":1,"expect":1,"explicit":[0,1],"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fig":[0,1],"figur":[0,1],"first":1,"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_local":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":0,"goal":0,"good":1,"graph_object":0,"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"infer":1,"info":1,"info_color":0,"inform":0,"input":0,"insoformat":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":[0,1],"keep":0,"key":1,"ki":1,"kwarg":1,"label":[0,1],"languag":1,"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"list":1,"local":1,"look":0,"m":1,"magnitud":0,"main":0,"make":0,"marker":0,"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"miss":0,"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"non":1,"none":1,"note":[0,1],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"orang":1,"order":0,"otherwis":0,"output":1,"packag":1,"panda":1,"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":1,"platform":1,"pleas":1,"plot":1,"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"properti":0,"provid":[0,1],"provis":0,"purpos":0,"pytz":1,"queri":1,"rais":1,"rang":0,"re":1,"reason":0,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"repres":0,"request":[0,1],"resolv":1,"resolve_color":1,"result":1,"retriev":[0,1],"return":[0,1],"ruhr":1,"s":[0,1],"say":0,"scatter":0,"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"set_agnostic_them":1,"set_dt_tick":1,"set_language_agnostic_datetime_tick":[],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"similar":1,"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"target":1,"tbd":1,"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":1,"tick":1,"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"to_datetim":1,"to_timezon":1,"toggleabl":1,"total_second":1,"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"update_layout":0,"update_xax":0,"us":1,"use":1,"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"whose":1,"will":[0,1],"write":1,"x":[0,1],"y":0,"yaxis_titl":0,"yield":1,"zone":1,"zoom":1},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"except":1,"explan":0,"first":0,"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file +Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{"get_display_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_display_names",false]],"get_locale() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.get_locale",false]],"get_measurements() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_measurements",false]],"get_metric_info() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_metric_info",false]],"get_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_names",false]],"get_queried_interval() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_queried_interval",false]],"get_series_display_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_display_name",false]],"get_series_info() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_info",false]],"get_series_measurement() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_measurement",false]],"get_series_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_name",false]],"get_series_short_display_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_short_display_name",false]],"get_series_unit() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_unit",false]],"get_short_display_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_short_display_names",false]],"get_units() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_units",false]],"hdhelpers.exceptions":[[1,"module-hdhelpers.exceptions",false]],"hdhelpers.helpers":[[1,"module-hdhelpers.helpers",false]],"hdhelpers.metadata":[[1,"module-hdhelpers.metadata",false]],"helperexception":[[1,"hdhelpers.exceptions.HelperException",false]],"insufficientplottingdata":[[1,"hdhelpers.exceptions.InsufficientPlottingData",false]],"modify_timezone() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.modify_timezone",false]],"module":[[1,"module-hdhelpers.exceptions",false],[1,"module-hdhelpers.helpers",false],[1,"module-hdhelpers.metadata",false]],"resolve_color() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.resolve_color",false]],"set_agnostic_theme() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.set_agnostic_theme",false]],"set_dt_ticks() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.set_dt_ticks",false]]},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"],[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"01t09":[],"01t10":[],"05t13":1,"06t13":1,"5s":0,"80b0ec":[],"A":1,"All":0,"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"avail":1,"awar":0,"axe":1,"axi":0,"background":1,"background_color":0,"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"brand":[],"by_metr":1,"c":1,"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"dark":1,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"de":1,"de_d":1,"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"doe":0,"draw":[],"e":1,"ea1255":1,"eas":1,"eb6962":1,"edg":0,"edit":0,"els":[],"empti":1,"en":1,"enabl":1,"end":[0,1],"energi":1,"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"exampl":[0,1],"exclus":1,"execcontext":[],"execut":1,"expect":1,"explicit":[0,1],"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fail":[],"featur":[],"fig":[0,1],"figur":[0,1],"first":1,"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_local":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":[0,1],"goal":0,"good":1,"graph_object":[0,1],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"infer":1,"info":1,"info_color":0,"inform":0,"inpir":[],"input":0,"insoformat":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":[0,1],"keep":0,"key":1,"ki":1,"kwarg":1,"label":[0,1],"languag":1,"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"list":1,"load":[],"local":1,"look":0,"m":1,"magnitud":0,"main":0,"make":0,"marker":0,"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"non":1,"none":1,"note":[0,1],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"orang":1,"order":0,"otherwis":0,"output":1,"packag":1,"panda":1,"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":1,"platform":1,"pleas":1,"plot":1,"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"print":1,"properti":0,"provid":[0,1],"provis":0,"purpos":0,"put":[],"pytz":1,"queri":1,"rais":1,"rang":0,"re":1,"reason":0,"red":1,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"repres":0,"request":[0,1],"resolv":1,"resolve_color":1,"result":1,"retriev":[0,1],"return":[0,1],"ruhr":1,"runtim":[],"s":[0,1],"say":0,"scatter":[0,1],"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"set_agnostic_them":1,"set_dt_tick":1,"set_language_agnostic_datetime_tick":[],"sever":[],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"similar":1,"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"switch":[],"take":[],"target":1,"tbd":1,"tech":[],"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":[],"tick":1,"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"to_datetim":1,"to_timezon":1,"togeth":[],"toggleabl":1,"total_second":1,"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"update_layout":0,"update_xax":0,"us":1,"usag":[],"use":1,"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"whose":1,"will":[0,1],"write":1,"x":[0,1],"y":[0,1],"yaxis_titl":0,"yield":1,"zone":1,"zoom":1},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"exampl":[],"except":1,"explan":0,"first":0,"full":[],"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file diff --git a/src/hdhelpers/__init__.py b/src/hdhelpers/__init__.py index 2204863..61a69b3 100644 --- a/src/hdhelpers/__init__.py +++ b/src/hdhelpers/__init__.py @@ -1,4 +1,9 @@ -"""hdhelpers for easing coding in hetida designer""" +"""helper functions for writing components in hetida designer""" + +from hdhelpers.helpers.color import resolve_color +from hdhelpers.helpers.locale import get_locale +from hdhelpers.helpers.plotly_theme import set_agnostic_theme +from hdhelpers.helpers.timestamp_ticks import set_dt_ticks from . import exceptions, helpers, metadata from .exceptions import HelperException, InsufficientPlottingData @@ -15,4 +20,8 @@ "metadata", "helpers", "StatusColors", + "get_locale", + "resolve_color", + "set_agnostic_theme", + "set_dt_ticks", ] diff --git a/src/hdhelpers/helpers/locale.py b/src/hdhelpers/helpers/locale.py index efab657..8422b3b 100644 --- a/src/hdhelpers/helpers/locale.py +++ b/src/hdhelpers/helpers/locale.py @@ -14,6 +14,16 @@ def get_locale(explicit_locale: str | None = None) -> str | None: str | None: Extracted locale (like "de_DE") + Code example: + + .. doctest:: + + >>> get_locale("de_DE") # returns "de-DE" + 'de-DE' + + >>> print(get_locale()) # returns locale from plot target settings of execution or None + None + """ if explicit_locale: return explicit_locale.replace("_", "-") diff --git a/src/hdhelpers/helpers/plotly_theme.py b/src/hdhelpers/helpers/plotly_theme.py index c9e6ec0..17d8278 100644 --- a/src/hdhelpers/helpers/plotly_theme.py +++ b/src/hdhelpers/helpers/plotly_theme.py @@ -46,7 +46,7 @@ def set_agnostic_theme(fig: go.Figure) -> None: - """Set Plotly template of figure to the theme_agnostic_template + """Set Plotly template of figure to a theme agnostic template This Plotly template should yield good results for both light and dark themed backgrounds. @@ -58,5 +58,13 @@ def set_agnostic_theme(fig: go.Figure) -> None: None: Returns None, since the figure object is modified in place + Code example: + + .. doctest:: + + >>> import plotly.graph_objects as go + >>> fig = go.Figure(data=go.Scatter(x=[1, 2, 3], y=[1, 4, 9])) + >>> set_agnostic_theme(fig) + """ fig.update_layout(template=theme_agnostic_template) diff --git a/src/hdhelpers/helpers/timestamp_ticks.py b/src/hdhelpers/helpers/timestamp_ticks.py index a3ac28a..71d792e 100644 --- a/src/hdhelpers/helpers/timestamp_ticks.py +++ b/src/hdhelpers/helpers/timestamp_ticks.py @@ -40,5 +40,13 @@ def set_dt_ticks(fig: go.Figure) -> None: None: Returns None, since the figure object is modified in place + Code example: + + .. doctest:: + + >>> import plotly.graph_objects as go + >>> fig = go.Figure(data=go.Scatter(x=["2024-01-01", "2024-01-02"], y=[1, 4])) + >>> set_dt_ticks(fig) + """ fig.update_xaxes(tickformatstops=TICKFORMATSTOPS) From ea1ba97c42da70aee351950c854764a79b5a5a73 Mon Sep 17 00:00:00 2001 From: stewit <> Date: Mon, 6 Jul 2026 15:05:05 +0200 Subject: [PATCH 4/7] index update --- docs/searchindex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/searchindex.js b/docs/searchindex.js index 779bb94..d8007cc 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{"get_display_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_display_names",false]],"get_locale() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.get_locale",false]],"get_measurements() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_measurements",false]],"get_metric_info() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_metric_info",false]],"get_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_names",false]],"get_queried_interval() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_queried_interval",false]],"get_series_display_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_display_name",false]],"get_series_info() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_info",false]],"get_series_measurement() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_measurement",false]],"get_series_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_name",false]],"get_series_short_display_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_short_display_name",false]],"get_series_unit() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_unit",false]],"get_short_display_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_short_display_names",false]],"get_units() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_units",false]],"hdhelpers.exceptions":[[1,"module-hdhelpers.exceptions",false]],"hdhelpers.helpers":[[1,"module-hdhelpers.helpers",false]],"hdhelpers.metadata":[[1,"module-hdhelpers.metadata",false]],"helperexception":[[1,"hdhelpers.exceptions.HelperException",false]],"insufficientplottingdata":[[1,"hdhelpers.exceptions.InsufficientPlottingData",false]],"modify_timezone() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.modify_timezone",false]],"module":[[1,"module-hdhelpers.exceptions",false],[1,"module-hdhelpers.helpers",false],[1,"module-hdhelpers.metadata",false]],"resolve_color() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.resolve_color",false]],"set_agnostic_theme() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.set_agnostic_theme",false]],"set_dt_ticks() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.set_dt_ticks",false]]},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"],[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"01t09":[],"01t10":[],"05t13":1,"06t13":1,"5s":0,"80b0ec":[],"A":1,"All":0,"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"avail":1,"awar":0,"axe":1,"axi":0,"background":1,"background_color":0,"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"brand":[],"by_metr":1,"c":1,"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"dark":1,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"de":1,"de_d":1,"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"doe":0,"draw":[],"e":1,"ea1255":1,"eas":1,"eb6962":1,"edg":0,"edit":0,"els":[],"empti":1,"en":1,"enabl":1,"end":[0,1],"energi":1,"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"exampl":[0,1],"exclus":1,"execcontext":[],"execut":1,"expect":1,"explicit":[0,1],"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fail":[],"featur":[],"fig":[0,1],"figur":[0,1],"first":1,"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_local":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":[0,1],"goal":0,"good":1,"graph_object":[0,1],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"infer":1,"info":1,"info_color":0,"inform":0,"inpir":[],"input":0,"insoformat":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":[0,1],"keep":0,"key":1,"ki":1,"kwarg":1,"label":[0,1],"languag":1,"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"list":1,"load":[],"local":1,"look":0,"m":1,"magnitud":0,"main":0,"make":0,"marker":0,"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"non":1,"none":1,"note":[0,1],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"orang":1,"order":0,"otherwis":0,"output":1,"packag":1,"panda":1,"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":1,"platform":1,"pleas":1,"plot":1,"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"print":1,"properti":0,"provid":[0,1],"provis":0,"purpos":0,"put":[],"pytz":1,"queri":1,"rais":1,"rang":0,"re":1,"reason":0,"red":1,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"repres":0,"request":[0,1],"resolv":1,"resolve_color":1,"result":1,"retriev":[0,1],"return":[0,1],"ruhr":1,"runtim":[],"s":[0,1],"say":0,"scatter":[0,1],"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"set_agnostic_them":1,"set_dt_tick":1,"set_language_agnostic_datetime_tick":[],"sever":[],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"similar":1,"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"switch":[],"take":[],"target":1,"tbd":1,"tech":[],"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":[],"tick":1,"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"to_datetim":1,"to_timezon":1,"togeth":[],"toggleabl":1,"total_second":1,"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"update_layout":0,"update_xax":0,"us":1,"usag":[],"use":1,"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"whose":1,"will":[0,1],"write":1,"x":[0,1],"y":[0,1],"yaxis_titl":0,"yield":1,"zone":1,"zoom":1},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"exampl":[],"except":1,"explan":0,"first":0,"full":[],"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file +Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"],[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"01t09":[],"01t10":[],"05t13":1,"06t13":1,"5s":0,"80b0ec":[],"A":1,"All":0,"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"avail":1,"awar":0,"axe":1,"axi":0,"background":1,"background_color":0,"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"brand":[],"by_metr":1,"c":1,"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"dark":1,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"de":1,"de_d":1,"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"doe":0,"draw":[],"e":1,"ea1255":1,"eas":1,"eb6962":1,"edg":0,"edit":0,"els":[],"empti":1,"en":1,"enabl":1,"end":[0,1],"energi":1,"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"exampl":[0,1],"exclus":1,"execcontext":[],"execut":1,"expect":1,"explicit":[0,1],"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fail":[],"featur":[],"fig":[0,1],"figur":[0,1],"first":1,"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_local":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":[0,1],"goal":0,"good":1,"graph_object":[0,1],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"infer":1,"info":1,"info_color":0,"inform":0,"inpir":[],"input":0,"insoformat":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":[0,1],"keep":0,"key":1,"ki":1,"kwarg":1,"label":[0,1],"languag":1,"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"list":1,"load":[],"local":1,"look":0,"m":1,"magnitud":0,"main":0,"make":0,"marker":0,"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"non":1,"none":1,"note":[0,1],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"orang":1,"order":0,"otherwis":0,"output":1,"packag":1,"panda":1,"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":1,"platform":1,"pleas":1,"plot":1,"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"print":1,"properti":0,"provid":[0,1],"provis":0,"purpos":0,"put":[],"pytz":1,"queri":1,"rais":1,"rang":0,"re":1,"reason":0,"red":1,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"repres":0,"request":[0,1],"resolv":1,"resolve_color":1,"result":1,"retriev":[0,1],"return":[0,1],"ruhr":1,"runtim":[],"s":[0,1],"say":0,"scatter":[0,1],"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"set_agnostic_them":1,"set_dt_tick":1,"set_language_agnostic_datetime_tick":[],"sever":[],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"similar":1,"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"switch":[],"take":[],"target":1,"tbd":1,"tech":[],"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":[],"tick":1,"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"to_datetim":1,"to_timezon":1,"togeth":[],"toggleabl":1,"total_second":1,"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"update_layout":0,"update_xax":0,"us":1,"usag":[],"use":1,"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"whose":1,"will":[0,1],"write":1,"x":[0,1],"y":[0,1],"yaxis_titl":0,"yield":1,"zone":1,"zoom":1},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"exampl":[],"except":1,"explan":0,"first":0,"full":[],"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file From 1454c83a86a18063b659c620ed9b539f6d5e86aa Mon Sep 17 00:00:00 2001 From: stewit <> Date: Mon, 6 Jul 2026 15:53:03 +0200 Subject: [PATCH 5/7] add fuseki color cycle --- src/hdhelpers/__init__.py | 3 ++- src/hdhelpers/helpers/__init__.py | 3 ++- src/hdhelpers/helpers/color.py | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/hdhelpers/__init__.py b/src/hdhelpers/__init__.py index 61a69b3..73a7f2e 100644 --- a/src/hdhelpers/__init__.py +++ b/src/hdhelpers/__init__.py @@ -1,6 +1,6 @@ """helper functions for writing components in hetida designer""" -from hdhelpers.helpers.color import resolve_color +from hdhelpers.helpers.color import FUSEKI_COLOR_CYCLE, resolve_color from hdhelpers.helpers.locale import get_locale from hdhelpers.helpers.plotly_theme import set_agnostic_theme from hdhelpers.helpers.timestamp_ticks import set_dt_ticks @@ -24,4 +24,5 @@ "resolve_color", "set_agnostic_theme", "set_dt_ticks", + "FUSEKI_COLOR_CYCLE", ] diff --git a/src/hdhelpers/helpers/__init__.py b/src/hdhelpers/helpers/__init__.py index 06bbff3..a92e9fc 100644 --- a/src/hdhelpers/helpers/__init__.py +++ b/src/hdhelpers/helpers/__init__.py @@ -1,6 +1,6 @@ """Collection of useful functions to ease some operations in hetida designer code.""" -from .color import resolve_color +from .color import FUSEKI_COLOR_CYCLE, resolve_color from .locale import get_locale from .plotly_theme import set_agnostic_theme, theme_agnostic_template from .timestamp_ticks import TICKFORMATSTOPS, set_dt_ticks @@ -14,4 +14,5 @@ "set_dt_ticks", "theme_agnostic_template", "set_agnostic_theme", + "FUSEKI_COLOR_CYCLE", ] diff --git a/src/hdhelpers/helpers/color.py b/src/hdhelpers/helpers/color.py index b3294e8..3050101 100644 --- a/src/hdhelpers/helpers/color.py +++ b/src/hdhelpers/helpers/color.py @@ -25,6 +25,19 @@ "ki.purple": "#bd7abb", # purple } +FUSEKI_COLOR_CYCLE = [ + FUSEKI_COLORS["ki.green"], + FUSEKI_COLORS["ki.orange"], + FUSEKI_COLORS["ki.blue"], + FUSEKI_COLORS["ki.red"], + FUSEKI_COLORS["ki.purple"], + FUSEKI_COLORS["ki.yellow"], + FUSEKI_COLORS["ki.gray"], + FUSEKI_COLORS["ki.lightgreen"], + FUSEKI_COLORS["ki.lightorange"], + FUSEKI_COLORS["ki.lightyellow"], +] + def resolve_color(color_str: str) -> str: """Resolves Fuseki Colors and returns resulting color string From 9a893fdb8c76ff80df4248c0ab4f7a40dce7925f Mon Sep 17 00:00:00 2001 From: jenny kupzigSCRIPT Date: Mon, 6 Jul 2026 15:07:39 +0000 Subject: [PATCH 6/7] Move functions to submodul "plotting", update docs, make TICKFORMATSTOPS importable from hdhelpers directly --- docs/_sources/first_steps.rst.txt | 27 +++++---------- docs/_sources/index.rst.txt | 11 ++++++ docs/first_steps.html | 32 ++++++------------ docs/genindex.html | 15 ++++++-- docs/index.html | 25 +++++++++----- docs/objects.inv | Bin 483 -> 496 bytes docs/py-modindex.html | 5 +++ docs/searchindex.js | 2 +- pyproject.toml | 4 +-- sphinx/source/conf.py | 1 + sphinx/source/first_steps.rst | 27 +++++---------- sphinx/source/index.rst | 11 ++++++ src/hdhelpers/__init__.py | 19 ++++++----- src/hdhelpers/helpers/__init__.py | 9 ----- src/hdhelpers/plotting/__init__.py | 14 ++++++++ src/hdhelpers/{helpers => plotting}/color.py | 0 .../{helpers => plotting}/plotly_theme.py | 0 .../{helpers => plotting}/timestamp_ticks.py | 0 .../test_color_handling.py | 2 +- uv.lock | 2 +- 20 files changed, 114 insertions(+), 92 deletions(-) create mode 100644 src/hdhelpers/plotting/__init__.py rename src/hdhelpers/{helpers => plotting}/color.py (100%) rename src/hdhelpers/{helpers => plotting}/plotly_theme.py (100%) rename src/hdhelpers/{helpers => plotting}/timestamp_ticks.py (100%) rename tests/{helpers => plotting}/test_color_handling.py (79%) diff --git a/docs/_sources/first_steps.rst.txt b/docs/_sources/first_steps.rst.txt index fd7d6e0..c2a396f 100644 --- a/docs/_sources/first_steps.rst.txt +++ b/docs/_sources/first_steps.rst.txt @@ -65,8 +65,9 @@ Our component code might look like this to plot the timeseries accordingly: .. code-block:: python - from hdhelpers.plotting import get_and_pad_start_and_end_timestamp, get_y_axis_label, plotly_fig_to_json_dict - from hdhelpers.helpers import modify_timezone + from hdhelpers.plotting import set_agnostic_theme, set_dt_ticks, resolve_color + from hdhelpers.helpers import get_locale, modify_timezone + from hdhelpers.metadata import get_queried_interval, get_series_name import plotly.graph_objects as go def main(*, series): @@ -75,26 +76,16 @@ Our component code might look like this to plot the timeseries accordingly: series = modify_timezone(series) - colors = get_colors_from_plot_target_settings() - fig = go.Figure([go.Scatter(x=series.index, y=series.values, marker={"color": colors.status_colors.warn_color})]) + fig = go.Figure([go.Scatter(x=series.index, y=series.values, marker={"color": resolve_color("ki.vision")})]) - start, end = get_and_pad_start_and_end_timestamp(series=series, start_padding='5s') + start, end = get_queried_interval(series=series) fig.update_xaxes(range=(start, end)) - full_title = get_y_axis_label(series=series, default_title="Level") + full_title = get_series_name(series=series, default_title="Level") fig.update_layout(yaxis_title=full_title) - return {"plot": plotly_fig_to_json_dict(fig=fig)} + set_dt_ticks(fig) + set_agnostic_theme(fig) -Explanation ------------ + return {"plot": fig} -- *modify_timezone*: We use `modify_timezone` function to set the timezone. Since our goal is just to make sure that the timestamps are timezone aware, not to convert it to a specific timezone, we do not pass a value for the `timezone` parameter. That way, if there is a `plot_target_timezone` set in the hetida designer's `plot_target_settings` context variable, that timezone will be used. Otherwise, the timestamps keep their current timezone or are converted to UTC if they are timezone naive. - -- *get_colors_from_plot_target_settings*: To use a (global) standard color, we use `get_colors_from_plot_target_settings`, which returns the `plot_target_style` property of the `plot_target_settings` context variable. It contains a set of colors with specific purposes, such as `background_color`, and the `status_colors` object, which in turn contains the four status colors: `success_color`, `error_color`, `warn_color`, and `info_color`. The status colors have no hardwired use in a plot, but are intended to convey a message. In our example, we want to communicate that the order of magnitude of our data is potentially dangerous, so we use the `warn_color` for `fig`'s `marker["color"]` property, which determines the plot's marker and line color. - -- *get_and_pad_start_and_end_timestamp*: We use `get_and_pad_start_and_end_timestamp` for precise control over the x-axis range. We do not set `start` and `end` explicitly because we want to parse them from the metadata, which reflects the chosen interval for which the data was requested. This way, we can see that there is missing data from 8:18 to 8:20. In the default behaviour of plotly this time range would not have been included possibly hiding missing data. Note: (1) We do not pass a `timezone` for the same reasons as with `modify_timezone`. (2) We also set a `start_padding`, so the markers of the first data point is not cut in half by the edge of the plot. - -- *get_y_axis_label*: We use `get_y_axis_label` so our y-axis can be labeled by using information from the metadata. With the above input series, title and unit will be parsed from the metadata. In case the metadata does not contain the mentioned information, we provide a `default_title`, and `default_unit` to configure the axis label in such cases. - -- *plotly_fig_to_json_dict*: We use `plotly_fig_to_json_dict` to apply standardized stylings and serialize the plotly figure into a json dict. All the standardized styling options are active by default, as detailed in [Styling Flags](#flags), so we do not have to set any for this example. diff --git a/docs/_sources/index.rst.txt b/docs/_sources/index.rst.txt index e902d3a..b6ca2c0 100644 --- a/docs/_sources/index.rst.txt +++ b/docs/_sources/index.rst.txt @@ -48,6 +48,17 @@ helpers :members: :show-inheritance: + + +plotting +------------------ + +.. automodule:: hdhelpers.plotting + :members: + :show-inheritance: + + + exceptions ------------------- diff --git a/docs/first_steps.html b/docs/first_steps.html index 58fe4d5..5796262 100644 --- a/docs/first_steps.html +++ b/docs/first_steps.html @@ -94,8 +94,9 @@

    How to use hdhelpers for plotting? (tbd)
    from hdhelpers.plotting import get_and_pad_start_and_end_timestamp, get_y_axis_label, plotly_fig_to_json_dict
    -from hdhelpers.helpers import modify_timezone
    +
    -
    -

    Explanation

    -
      -
    • modify_timezone: We use modify_timezone function to set the timezone. Since our goal is just to make sure that the timestamps are timezone aware, not to convert it to a specific timezone, we do not pass a value for the timezone parameter. That way, if there is a plot_target_timezone set in the hetida designer’s plot_target_settings context variable, that timezone will be used. Otherwise, the timestamps keep their current timezone or are converted to UTC if they are timezone naive.

    • -
    • get_colors_from_plot_target_settings: To use a (global) standard color, we use get_colors_from_plot_target_settings, which returns the plot_target_style property of the plot_target_settings context variable. It contains a set of colors with specific purposes, such as background_color, and the status_colors object, which in turn contains the four status colors: success_color, error_color, warn_color, and info_color. The status colors have no hardwired use in a plot, but are intended to convey a message. In our example, we want to communicate that the order of magnitude of our data is potentially dangerous, so we use the warn_color for fig’s marker[“color”] property, which determines the plot’s marker and line color.

    • -
    • get_and_pad_start_and_end_timestamp: We use get_and_pad_start_and_end_timestamp for precise control over the x-axis range. We do not set start and end explicitly because we want to parse them from the metadata, which reflects the chosen interval for which the data was requested. This way, we can see that there is missing data from 8:18 to 8:20. In the default behaviour of plotly this time range would not have been included possibly hiding missing data. Note: (1) We do not pass a timezone for the same reasons as with modify_timezone. (2) We also set a start_padding, so the markers of the first data point is not cut in half by the edge of the plot.

    • -
    • get_y_axis_label: We use get_y_axis_label so our y-axis can be labeled by using information from the metadata. With the above input series, title and unit will be parsed from the metadata. In case the metadata does not contain the mentioned information, we provide a default_title, and default_unit to configure the axis label in such cases.

    • -
    • plotly_fig_to_json_dict: We use plotly_fig_to_json_dict to apply standardized stylings and serialize the plotly figure into a json dict. All the standardized styling options are active by default, as detailed in [Styling Flags](#flags), so we do not have to set any for this example.

    • -
    -
    @@ -141,10 +134,7 @@

    Table of Contents

    diff --git a/docs/genindex.html b/docs/genindex.html index 203c4fe..9f53d9d 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -107,6 +107,13 @@

    H

    +
  • + hdhelpers.plotting + +
  • HelperException @@ -136,6 +143,8 @@

    M

  • hdhelpers.helpers
  • hdhelpers.metadata +
  • +
  • hdhelpers.plotting
  • @@ -144,7 +153,7 @@

    M

    R

    @@ -152,11 +161,11 @@

    R

    S

    diff --git a/docs/index.html b/docs/index.html index 9f1fa2b..fe63edd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -659,9 +659,13 @@

    Functions +

    plotting

    +

    Collection of useful functions to ease plotting.

    -
    -hdhelpers.helpers.resolve_color(color_str)
    +
    +hdhelpers.plotting.resolve_color(color_str)

    Resolves Fuseki Colors and returns resulting color string

    Non-fuseki (color) strings are returned just as they are.

    @@ -685,8 +689,8 @@

    Functions -
    -hdhelpers.helpers.set_agnostic_theme(fig)
    +
    +hdhelpers.plotting.set_agnostic_theme(fig)

    Set Plotly template of figure to a theme agnostic template

    This Plotly template should yield good results for both light and dark themed backgrounds.

    @@ -710,8 +714,8 @@

    Functions -
    -hdhelpers.helpers.set_dt_ticks(fig)
    +
    +hdhelpers.plotting.set_dt_ticks(fig)

    Set x datetime tick labels to language agnostic format

    Sets the x axes tick format of the Plotly Figure to some isoformat inspired timestamp format, adequately for multiple zoom levels.

    @@ -821,9 +825,12 @@

    Table of Contents

  • helpers +
  • +
  • plotting
  • exceptions
      diff --git a/docs/objects.inv b/docs/objects.inv index 6bc4d94758263850474802f32e3662b4a81198de..495e45d50c31808c5152eed44ffeb46acb82e3d9 100644 GIT binary patch delta 384 zcmV-`0e}AE1MmZod4ElAgD?<<_ng8~y9G7dtlO$tREpFCAlDwSRbx}n5QUz;215!; zs}Rza(HnnnevGZ80#k#>42}Y7(#|5Q+im4!V}Ly{Z6zEtMU}aWT6)jYME!zgFTM0M z3Z2a<$~IG{KP`3^o1)M{gQdN3MB0{*ocLm|VZEw_aV>#z<9`GXP{51EiiO#-V5^HZ zCtbmpvy1Txh|8h7#np~bU#`?x8{X!YSAf^1?HwxM*m$VIz}Fg(*CN-paI5(BrGGZy zHOP>fz#q6-WrCdt&IWml&+0J@{Ny-pvAMMkRL;}C4W+SqWjAMKtou{C0v40?@a|l7 zD@Q2vfX*Bs7kSP&e{ISPL$SQH4k=tIQm}mPGYd)KEfOCWS}wH5Fk^xm8Is&eCs?{+ z6S?2Zo;!i{LQ;b5U3$RqcQ73?s&W6W`%Hee4Zf2dr?Qjo;5D8@be=>n eVEdL-=zK;aa4*yxj9O&gVtmg_NWK9<{gzM-+rGvC delta 371 zcmV-(0gV3e1LFgbd4J1J!!Qs<_xTD-uuVj_T?3*Eq)L21Wb8?7;n=}5sT#f>=T%Y_ z)Wl`w=+2xw4@Xu~fvLe`21fxkX=jnu?Y45VF~A;}wi1q+qRQM2T6)jYME!zgFTM0M z37yR;$~JSSKP`3^o1)M{gQdN3MB0{*ocLm|@mw{+be2H5aesmbDBwk7#lmV?u+>GI zldj;)+10oQbmjoLaK`zyFov#qX&sUlIVq?h#z9i(UVPwEwgTdEyqLv{o}hlyQe$m+ zn_FJN>ax8<1soe62DTJyKt3!@+rmZh@vVP0;5Eoln!q2pi88^?1J4$Di%;|#Mt*i3 zx7ge|1}f+2-)xrBSRFadMH_K{O4q;@vd|twL4q0?lH5usSh`^|xzACO>JT?=0igbJD$lmwt7dPJsb<9iEE8c^18b?ORe|@-rHNd!f$3 RK^vI2A-?A&B;WU3f%9I}xDNmT diff --git a/docs/py-modindex.html b/docs/py-modindex.html index 5a65f5b..6d07dff 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -70,6 +70,11 @@

      Python Module Index

          hdhelpers.metadata + + +     + hdhelpers.plotting + diff --git a/docs/searchindex.js b/docs/searchindex.js index d8007cc..a5da6b5 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"],[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"01t09":[],"01t10":[],"05t13":1,"06t13":1,"5s":0,"80b0ec":[],"A":1,"All":0,"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"avail":1,"awar":0,"axe":1,"axi":0,"background":1,"background_color":0,"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"brand":[],"by_metr":1,"c":1,"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"dark":1,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"de":1,"de_d":1,"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"doe":0,"draw":[],"e":1,"ea1255":1,"eas":1,"eb6962":1,"edg":0,"edit":0,"els":[],"empti":1,"en":1,"enabl":1,"end":[0,1],"energi":1,"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"exampl":[0,1],"exclus":1,"execcontext":[],"execut":1,"expect":1,"explicit":[0,1],"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fail":[],"featur":[],"fig":[0,1],"figur":[0,1],"first":1,"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_local":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":[0,1],"goal":0,"good":1,"graph_object":[0,1],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"infer":1,"info":1,"info_color":0,"inform":0,"inpir":[],"input":0,"insoformat":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":[0,1],"keep":0,"key":1,"ki":1,"kwarg":1,"label":[0,1],"languag":1,"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"list":1,"load":[],"local":1,"look":0,"m":1,"magnitud":0,"main":0,"make":0,"marker":0,"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"non":1,"none":1,"note":[0,1],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"orang":1,"order":0,"otherwis":0,"output":1,"packag":1,"panda":1,"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":1,"platform":1,"pleas":1,"plot":1,"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"print":1,"properti":0,"provid":[0,1],"provis":0,"purpos":0,"put":[],"pytz":1,"queri":1,"rais":1,"rang":0,"re":1,"reason":0,"red":1,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"repres":0,"request":[0,1],"resolv":1,"resolve_color":1,"result":1,"retriev":[0,1],"return":[0,1],"ruhr":1,"runtim":[],"s":[0,1],"say":0,"scatter":[0,1],"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"set_agnostic_them":1,"set_dt_tick":1,"set_language_agnostic_datetime_tick":[],"sever":[],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"similar":1,"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"switch":[],"take":[],"target":1,"tbd":1,"tech":[],"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":[],"tick":1,"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"to_datetim":1,"to_timezon":1,"togeth":[],"toggleabl":1,"total_second":1,"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"update_layout":0,"update_xax":0,"us":1,"usag":[],"use":1,"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"whose":1,"will":[0,1],"write":1,"x":[0,1],"y":[0,1],"yaxis_titl":0,"yield":1,"zone":1,"zoom":1},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"exampl":[],"except":1,"explan":0,"first":0,"full":[],"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}}) \ No newline at end of file +Search.setIndex({"alltitles":{"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]],"plotting":[[1,"module-hdhelpers.plotting"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{"get_display_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_display_names",false]],"get_locale() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.get_locale",false]],"get_measurements() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_measurements",false]],"get_metric_info() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_metric_info",false]],"get_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_names",false]],"get_queried_interval() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_queried_interval",false]],"get_series_display_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_display_name",false]],"get_series_info() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_info",false]],"get_series_measurement() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_measurement",false]],"get_series_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_name",false]],"get_series_short_display_name() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_short_display_name",false]],"get_series_unit() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_series_unit",false]],"get_short_display_names() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_short_display_names",false]],"get_units() (in module hdhelpers.metadata)":[[1,"hdhelpers.metadata.get_units",false]],"hdhelpers.exceptions":[[1,"module-hdhelpers.exceptions",false]],"hdhelpers.helpers":[[1,"module-hdhelpers.helpers",false]],"hdhelpers.metadata":[[1,"module-hdhelpers.metadata",false]],"hdhelpers.plotting":[[1,"module-hdhelpers.plotting",false]],"helperexception":[[1,"hdhelpers.exceptions.HelperException",false]],"insufficientplottingdata":[[1,"hdhelpers.exceptions.InsufficientPlottingData",false]],"modify_timezone() (in module hdhelpers.helpers)":[[1,"hdhelpers.helpers.modify_timezone",false]],"module":[[1,"module-hdhelpers.exceptions",false],[1,"module-hdhelpers.helpers",false],[1,"module-hdhelpers.metadata",false],[1,"module-hdhelpers.plotting",false]],"resolve_color() (in module hdhelpers.plotting)":[[1,"hdhelpers.plotting.resolve_color",false]],"set_agnostic_theme() (in module hdhelpers.plotting)":[[1,"hdhelpers.plotting.set_agnostic_theme",false]],"set_dt_ticks() (in module hdhelpers.plotting)":[[1,"hdhelpers.plotting.set_dt_ticks",false]]},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"],[1,0,0,"-","plotting"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","get_locale"],[1,2,1,"","modify_timezone"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]],"hdhelpers.plotting":[[1,2,1,"","resolve_color"],[1,2,1,"","set_agnostic_theme"],[1,2,1,"","set_dt_ticks"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"05t13":1,"06t13":1,"5s":[],"A":1,"All":[],"As":[],"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":1,"NOT":0,"Our":0,"That":[],"The":[],"Then":[],"This":1,"To":1,"We":0,"With":[],"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":[],"add_config_set":[],"adequ":1,"adit":1,"adjust":1,"agnost":1,"all_timezon":1,"allow":1,"also":[],"ani":1,"anoth":1,"appli":[],"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"autoexpand":[],"avail":1,"awar":[],"axe":1,"axes_label_color":[],"axi":0,"b":[],"background":1,"background_color":[],"bar":[],"base":1,"becaus":[],"behaviour":1,"berlin":1,"bool":1,"boolean":1,"by_metr":1,"c":1,"call":[],"can":[0,1],"case":1,"certain":1,"chosen":[],"circl":[],"class":1,"cm":0,"code":[0,1],"collect":1,"color":[0,1],"color_str":1,"colorway":[],"column":1,"column_nam":1,"communic":[],"compli":1,"compon":[0,1],"concret":1,"configur":[],"contain":1,"context":1,"contrast":1,"control":1,"convent":1,"convert":1,"convert_index":1,"convey":[],"correct":[],"correspond":[0,1],"current":[],"custom":1,"cut":[],"danger":[],"dark":1,"data":1,"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"datetime_tick_format":[],"de":1,"de_d":1,"def":0,"default":1,"default_titl":0,"default_unit":[],"defaultdict":1,"defin":[0,1],"deprec":[],"design":[0,1],"detail":[],"determin":[],"dict":1,"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"displaylogo":[],"displaymodebar":[],"doe":[],"e":1,"ea1255":1,"eas":1,"eb6962":1,"edg":[],"edit":0,"empti":1,"en":1,"enabl":1,"end":[0,1],"energi":1,"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":[],"especi":1,"europ":1,"ever":[],"exampl":[0,1],"exclus":1,"execut":1,"expect":1,"explan":[],"explicit":1,"explicit_local":1,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fals":[],"fig":[0,1],"figur":[0,1],"find":[],"first":1,"fit":[],"flag":[],"follow":[0,1],"format":1,"four":[],"frontend":1,"full_titl":0,"function":0,"fuseki":1,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":[],"get_colors_from_plot_target_set":[],"get_display_nam":1,"get_local":[0,1],"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":[0,1],"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":[],"given":1,"global":1,"glom":1,"go":[0,1],"goal":[],"good":1,"graph_object":[0,1],"grid":[],"grid_color":[],"half":[],"handl":1,"happen":1,"hardwir":[],"helper":0,"helperexcept":1,"hetida":[0,1],"hide":[],"hide_legend":[],"hide_x_titl":[],"higher":[],"id":1,"import":[0,1],"includ":1,"index":[0,1],"infer":1,"info":1,"info_color":[],"inform":[],"input":[],"inspir":1,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":[],"interpret":1,"interv":1,"iso":1,"isoformat":1,"json":[0,1],"just":1,"keep":[],"key":1,"ki":[0,1],"kwarg":1,"l":[],"label":[0,1],"languag":1,"last":[],"layout":[],"leav":[],"legend":[],"let":[0,1],"level":[0,1],"light":1,"like":[0,1],"limit":0,"line":0,"line_color":[],"list":1,"local":1,"logo":[],"look":0,"m":1,"magnitud":[],"main":0,"make":[],"margin":[],"marker":0,"marker_symbol":[],"match":[],"meaning":1,"measur":1,"mention":[],"messag":1,"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"minim":[],"miss":[],"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"modifyng":[],"mtsf":1,"multipl":1,"multitsfram":1,"naiv":[],"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"necessari":[],"next":[],"non":1,"none":1,"normal":[],"note":1,"now":[],"object":1,"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":1,"orang":1,"order":[],"otherwis":[],"output":1,"packag":1,"pad":[],"panda":1,"paper":[],"paper_bgcolor":[],"paramet":1,"pars":[],"pass":[],"pd":1,"place":1,"platform":1,"pleas":1,"plot":[],"plot_bgcolor":[],"plot_target_local":[],"plot_target_set":1,"plot_target_styl":[],"plot_target_timezon":[],"plotly_fig_to_json_dict":[],"point":[],"possibl":1,"potenti":[],"precis":[],"present":1,"print":1,"prioriti":[],"properti":[],"provid":1,"provis":0,"purpos":[],"pytz":1,"queri":1,"r":[],"rais":1,"rang":0,"rare":[],"re":1,"reason":[],"red":1,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":[],"remov":[],"remove_plotly_bar":[],"remove_plotly_icon":[],"repres":0,"request":1,"resolv":1,"resolve_color":[0,1],"result":1,"retriev":[0,1],"return":[0,1],"rgba":[],"ruhr":1,"run":[],"s":[0,1],"said":[],"say":0,"scatter":[0,1],"scheme":1,"second":1,"see":1,"sensibl":1,"seri":[0,1],"serial":1,"set":[0,1],"set_agnostic_them":[0,1],"set_dt_tick":[0,1],"shade":1,"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"showlegend":[],"similar":1,"simple_whit":[],"sinc":1,"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"size":[],"soon":[],"spec":1,"specif":[],"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":[],"status":[],"status_color":[],"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":1,"success_color":[],"sure":[],"surpress":1,"t":[],"target":1,"tbd":1,"temp":1,"temperatur":1,"templat":1,"test":1,"theme":1,"theme_agnostic_templ":[],"tick":1,"tickformat":[],"time":1,"timeseri":[0,1],"timestamp":1,"timezon":[0,1],"titl":[],"title_standoff":[],"title_text":[],"to_datetim":1,"to_timezon":1,"toggleabl":1,"total_second":1,"trace":[],"transform":1,"tri":1,"true":1,"tupl":1,"turn":[],"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"unless":[],"updat":[],"update_layout":0,"update_x_axes_tickformat":[],"update_xax":0,"us":1,"use":1,"use_default_standoff":[],"use_minimum_margin":[],"use_muplot_axes_color":[],"use_muplot_grid":[],"use_muplot_line_and_mark":[],"use_platform_background":[],"use_platform_colorway":[],"use_platform_default":[],"use_simple_white_templ":[],"utc":1,"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":1,"via":1,"visibl":[],"vision":0,"want":0,"warn_color":[],"water":0,"way":1,"well":1,"whether":1,"whose":1,"width":[],"will":1,"without":[],"write":1,"wwe":[],"x":[0,1],"xax":[],"y":[0,1],"yax":[],"yaxis_titl":0,"yield":1,"zone":1,"zoom":1,"\u00b5plot":[]},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"except":1,"explan":[],"first":0,"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":[0,1],"step":0,"tbd":0,"use":0}}) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 0b5d536..b3b0962 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ exclude = [ [project] name = "hdhelpers" -version = "0.0.4" +version = "0.0.5" description = "Streamlines metadata & timezone handling, and plotting in hetida designer components" readme = "README.md" maintainers = [ @@ -109,4 +109,4 @@ ignore_missing_imports = true [[tool.mypy.overrides]] module = ["plotly", "plotly.*"] -ignore_missing_imports = true \ No newline at end of file +ignore_missing_imports = true diff --git a/sphinx/source/conf.py b/sphinx/source/conf.py index f573e6a..c576c49 100644 --- a/sphinx/source/conf.py +++ b/sphinx/source/conf.py @@ -53,6 +53,7 @@ from hdhelpers import * from hdhelpers.metadata import * from hdhelpers.helpers import * + from hdhelpers.plotting import * series = pd.Series() dataframe = pd.DataFrame() diff --git a/sphinx/source/first_steps.rst b/sphinx/source/first_steps.rst index fd7d6e0..c2a396f 100644 --- a/sphinx/source/first_steps.rst +++ b/sphinx/source/first_steps.rst @@ -65,8 +65,9 @@ Our component code might look like this to plot the timeseries accordingly: .. code-block:: python - from hdhelpers.plotting import get_and_pad_start_and_end_timestamp, get_y_axis_label, plotly_fig_to_json_dict - from hdhelpers.helpers import modify_timezone + from hdhelpers.plotting import set_agnostic_theme, set_dt_ticks, resolve_color + from hdhelpers.helpers import get_locale, modify_timezone + from hdhelpers.metadata import get_queried_interval, get_series_name import plotly.graph_objects as go def main(*, series): @@ -75,26 +76,16 @@ Our component code might look like this to plot the timeseries accordingly: series = modify_timezone(series) - colors = get_colors_from_plot_target_settings() - fig = go.Figure([go.Scatter(x=series.index, y=series.values, marker={"color": colors.status_colors.warn_color})]) + fig = go.Figure([go.Scatter(x=series.index, y=series.values, marker={"color": resolve_color("ki.vision")})]) - start, end = get_and_pad_start_and_end_timestamp(series=series, start_padding='5s') + start, end = get_queried_interval(series=series) fig.update_xaxes(range=(start, end)) - full_title = get_y_axis_label(series=series, default_title="Level") + full_title = get_series_name(series=series, default_title="Level") fig.update_layout(yaxis_title=full_title) - return {"plot": plotly_fig_to_json_dict(fig=fig)} + set_dt_ticks(fig) + set_agnostic_theme(fig) -Explanation ------------ + return {"plot": fig} -- *modify_timezone*: We use `modify_timezone` function to set the timezone. Since our goal is just to make sure that the timestamps are timezone aware, not to convert it to a specific timezone, we do not pass a value for the `timezone` parameter. That way, if there is a `plot_target_timezone` set in the hetida designer's `plot_target_settings` context variable, that timezone will be used. Otherwise, the timestamps keep their current timezone or are converted to UTC if they are timezone naive. - -- *get_colors_from_plot_target_settings*: To use a (global) standard color, we use `get_colors_from_plot_target_settings`, which returns the `plot_target_style` property of the `plot_target_settings` context variable. It contains a set of colors with specific purposes, such as `background_color`, and the `status_colors` object, which in turn contains the four status colors: `success_color`, `error_color`, `warn_color`, and `info_color`. The status colors have no hardwired use in a plot, but are intended to convey a message. In our example, we want to communicate that the order of magnitude of our data is potentially dangerous, so we use the `warn_color` for `fig`'s `marker["color"]` property, which determines the plot's marker and line color. - -- *get_and_pad_start_and_end_timestamp*: We use `get_and_pad_start_and_end_timestamp` for precise control over the x-axis range. We do not set `start` and `end` explicitly because we want to parse them from the metadata, which reflects the chosen interval for which the data was requested. This way, we can see that there is missing data from 8:18 to 8:20. In the default behaviour of plotly this time range would not have been included possibly hiding missing data. Note: (1) We do not pass a `timezone` for the same reasons as with `modify_timezone`. (2) We also set a `start_padding`, so the markers of the first data point is not cut in half by the edge of the plot. - -- *get_y_axis_label*: We use `get_y_axis_label` so our y-axis can be labeled by using information from the metadata. With the above input series, title and unit will be parsed from the metadata. In case the metadata does not contain the mentioned information, we provide a `default_title`, and `default_unit` to configure the axis label in such cases. - -- *plotly_fig_to_json_dict*: We use `plotly_fig_to_json_dict` to apply standardized stylings and serialize the plotly figure into a json dict. All the standardized styling options are active by default, as detailed in [Styling Flags](#flags), so we do not have to set any for this example. diff --git a/sphinx/source/index.rst b/sphinx/source/index.rst index e902d3a..b6ca2c0 100644 --- a/sphinx/source/index.rst +++ b/sphinx/source/index.rst @@ -48,6 +48,17 @@ helpers :members: :show-inheritance: + + +plotting +------------------ + +.. automodule:: hdhelpers.plotting + :members: + :show-inheritance: + + + exceptions ------------------- diff --git a/src/hdhelpers/__init__.py b/src/hdhelpers/__init__.py index 73a7f2e..260f570 100644 --- a/src/hdhelpers/__init__.py +++ b/src/hdhelpers/__init__.py @@ -1,23 +1,23 @@ """helper functions for writing components in hetida designer""" -from hdhelpers.helpers.color import FUSEKI_COLOR_CYCLE, resolve_color +from hdhelpers import exceptions, helpers, metadata, plotting +from hdhelpers.exceptions import HelperException, InsufficientPlottingData from hdhelpers.helpers.locale import get_locale -from hdhelpers.helpers.plotly_theme import set_agnostic_theme -from hdhelpers.helpers.timestamp_ticks import set_dt_ticks - -from . import exceptions, helpers, metadata -from .exceptions import HelperException, InsufficientPlottingData -from .plot_target_settings import StatusColors +from hdhelpers.plot_target_settings import StatusColors +from hdhelpers.plotting.color import FUSEKI_COLOR_CYCLE, resolve_color +from hdhelpers.plotting.plotly_theme import set_agnostic_theme +from hdhelpers.plotting.timestamp_ticks import TICKFORMATSTOPS, set_dt_ticks # do not edit line of __version__ as it is automatically modified by running ./run build_package -__version__ = "0.0.4" +__version__ = "0.0.5" -# function can be automated with from hdhelpers import * +# import can be done by using `from hdhelpers import *`` __all__ = [ "HelperException", "InsufficientPlottingData", "exceptions", "metadata", + "plotting", "helpers", "StatusColors", "get_locale", @@ -25,4 +25,5 @@ "set_agnostic_theme", "set_dt_ticks", "FUSEKI_COLOR_CYCLE", + "TICKFORMATSTOPS" ] diff --git a/src/hdhelpers/helpers/__init__.py b/src/hdhelpers/helpers/__init__.py index a92e9fc..0ea713f 100644 --- a/src/hdhelpers/helpers/__init__.py +++ b/src/hdhelpers/helpers/__init__.py @@ -1,18 +1,9 @@ """Collection of useful functions to ease some operations in hetida designer code.""" -from .color import FUSEKI_COLOR_CYCLE, resolve_color from .locale import get_locale -from .plotly_theme import set_agnostic_theme, theme_agnostic_template -from .timestamp_ticks import TICKFORMATSTOPS, set_dt_ticks from .timezone_handling import modify_timezone __all__ = [ "modify_timezone", - "resolve_color", "get_locale", - "TICKFORMATSTOPS", - "set_dt_ticks", - "theme_agnostic_template", - "set_agnostic_theme", - "FUSEKI_COLOR_CYCLE", ] diff --git a/src/hdhelpers/plotting/__init__.py b/src/hdhelpers/plotting/__init__.py new file mode 100644 index 0000000..3d7e8d8 --- /dev/null +++ b/src/hdhelpers/plotting/__init__.py @@ -0,0 +1,14 @@ +"""Collection of useful functions to ease plotting.""" + +from ..plotting.color import FUSEKI_COLOR_CYCLE, resolve_color +from ..plotting.plotly_theme import set_agnostic_theme, theme_agnostic_template +from ..plotting.timestamp_ticks import TICKFORMATSTOPS, set_dt_ticks + +__all__ = [ + "resolve_color", + "TICKFORMATSTOPS", + "set_dt_ticks", + "theme_agnostic_template", + "set_agnostic_theme", + "FUSEKI_COLOR_CYCLE", +] diff --git a/src/hdhelpers/helpers/color.py b/src/hdhelpers/plotting/color.py similarity index 100% rename from src/hdhelpers/helpers/color.py rename to src/hdhelpers/plotting/color.py diff --git a/src/hdhelpers/helpers/plotly_theme.py b/src/hdhelpers/plotting/plotly_theme.py similarity index 100% rename from src/hdhelpers/helpers/plotly_theme.py rename to src/hdhelpers/plotting/plotly_theme.py diff --git a/src/hdhelpers/helpers/timestamp_ticks.py b/src/hdhelpers/plotting/timestamp_ticks.py similarity index 100% rename from src/hdhelpers/helpers/timestamp_ticks.py rename to src/hdhelpers/plotting/timestamp_ticks.py diff --git a/tests/helpers/test_color_handling.py b/tests/plotting/test_color_handling.py similarity index 79% rename from tests/helpers/test_color_handling.py rename to tests/plotting/test_color_handling.py index 7736f77..5ae4346 100644 --- a/tests/helpers/test_color_handling.py +++ b/tests/plotting/test_color_handling.py @@ -1,4 +1,4 @@ -from hdhelpers.helpers import resolve_color +from hdhelpers.plotting import resolve_color def test_resolve_color(): diff --git a/uv.lock b/uv.lock index 34e024b..8b2ee18 100644 --- a/uv.lock +++ b/uv.lock @@ -263,7 +263,7 @@ wheels = [ [[package]] name = "hdhelpers" -version = "0.0.4" +version = "0.0.5" source = { editable = "." } dependencies = [ { name = "glom" }, From 34baebdead91314fd2d024cba3283a79891bd0b4 Mon Sep 17 00:00:00 2001 From: jenny kupzigSCRIPT Date: Mon, 6 Jul 2026 15:08:42 +0000 Subject: [PATCH 7/7] fix pipeline --- src/hdhelpers/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hdhelpers/__init__.py b/src/hdhelpers/__init__.py index 260f570..31f7bf2 100644 --- a/src/hdhelpers/__init__.py +++ b/src/hdhelpers/__init__.py @@ -25,5 +25,5 @@ "set_agnostic_theme", "set_dt_ticks", "FUSEKI_COLOR_CYCLE", - "TICKFORMATSTOPS" + "TICKFORMATSTOPS", ]