NSPanel Documentation โ—† Icon overview GitHub Deutsch

Pie chart page โ€“ configuration in the admin

The page cardPChart shows up to five values as a pie chart with a legend (the legend of HMI 6.0.5 has five rows). The panel computes the percentages itself; headline and legend use the font color of the panel. It needs TFT version 6.0.5 (EU panel).

A pie chart page is created in the PageConfig tab as a page of type Pie chart: configure everything in the editor, assign the navigation in the panel section. No script is needed; there is no page type for this card in the configuration script.

Creating the page in the PageConfig tab

In the PageConfig tab click the PLUS on the left, choose the type Pie chart and enter a unique page name (uniqueName, it must be unique across the whole panel). The editor then shows:

  1. Headline of the page.
  2. Legend: what is printed next to the name of each slice โ€“ the name only, name and value, name and percent, or name, value and percent (default).
  3. Decimal places of the value text (default 2). Applies to the values from states; with the script data point the text comes ready-made from the script.
  4. Data source: Values from states (default, see below) or Script data point (for existing scripts that build the panel text themselves).

The fields can only be edited while the adapter instance is running. Visibility (hide page), alwaysOn and the navigation are set in the navigation/panel assignment section like for every page.

Values from states (default)

The main view of the editor: a time range, a DB instance when needed and five rows for the slices.

Time range

The range is stored as a key (rangeKey: current, h1, d1, w1, m1, custom, today, yesterday, thisWeek, lastWeek, thisMonth, lastMonth), the hours (rangeHours) only for custom.

Slices

Per slice (1โ€“5):

A value of 0 keeps its legend line (without a piece in the pie), negative values count as 0. The order of the rows is the order in legend and pie.

The legend has a fixed width: names longer than about 20 characters and value texts longer than about 15 characters (next to the percentage; about 20 without it) are cut hard by the adapter so that nothing is written on top of each other โ€“ narrow characters count less, capitals and digits more. This applies to both data sources.

Script data point

For scripts that build the panel text themselves (for instance following the old NSPanel Lovelace script): one state the script writes the finished text into. Four fields per slice, separated by ~:

Name~Number~Value text~Color

Example: Grid~5200~5.20 kWh~63488~Self use~3100~3.10 kWh~2016~Feed-in~1500~1.50 kWh~2047

More than five slices: from the fifth on the adapter sums all remaining ones up as one slice Other (number = sum of the rest, no value text, color of the fifth slice), because the panel reads five entries only. A time range does not apply to this source.

What the adapter sends to the panel

The numbers of all slices are scaled with one common factor to integers whose sum is about 1 000 000 โ€“ the panel works with the sum in 32 bit and needs it below 2 000 000; small shares do not drop to 0. The decimals of the original values only appear in the value text. The panel reads at most five slices and computes the percentages itself.


Source of this page: doc/en/cardPChart.md ยท Project on GitHub

  Back to top