Struggling to add custom graph to my plugin

Hello Tom,

I have looked at your code at Codeberg.

In the file "com_falkensweb_hp_officejet_metric.py " you have only created a combined graph but have not defined the individual graph lines.

You must first define the individual line for the colors as follows:

metric_info["hp_officejet_remaining_Yellow"] = {
    "title": _("Remaining Yellow"),
    "unit": "%",
    "color": "23/a",
}

Repeat this with other colors.

and below that comes your block

graph_info["hp_officejet_remaining_combined"] = {
    "metrics": [
        ("hp_officejet_remaining_Yellow", "line"),
        ("hp_officejet_remaining_Magenta", "line"),
        ("hp_officejet_remaining_Cyan", "line"),
        ("hp_officejet_remaining_Black", "line"),
    ],
}

You can select the colors of the lines to match the ink from the following palette:

 Colors:

                   red
  magenta                       orange
            11 12 13 14 15 16
         46                   21
         45                   22
   blue  44                   23  yellow
         43                   24
         42                   25
         41                   26
            36 35 34 33 32 31
     cyan                       yellow-green
                  green

Special colors:
51  gray
52  brown 1
53  brown 2

For a new metric_info you have to choose a color. No more hex-codes are needed!
Instead you can choose a number of the above color ring and a letter 'a' or 'b
where 'a' represents the basic color and 'b' is a nuance/shading of the basic color.
Both number and letter must be declared!

Example:
"color" : "23/a" (basic color yellow)
"color" : "23/b" (nuance of color yellow)

As an alternative you can call indexed_color with a color index and the maximum
number of colors you will need to generate a color. This function tries to return
high contrast colors for "close" indices, so the colors of idx 1 and idx 2 may
have stronger contrast than the colors at idx 3 and idx 10.
retrieve an indexed color.
param idx: the color index
param total: the total number of colors needed in one graph.
1 Like