Changing the color of bars in a histogram chart

124 views
Skip to first unread message

Remy Lavabre

unread,
Sep 20, 2023, 3:19:50 AM9/20/23
to weewx-user
Good morning,

the option chart_fill_colors = is supposed to change the fill color of the bar charts (chart_fill_colors: A list of the color to be used as the fill of the bar charts. Optional. The default is to use the same color as the outline color ( option chart_line_colors).

But when in skin.conf I put
color = Red
chart_fill_colors = Red

I get blue histograms with a red border...
How to obtain red histograms?
THANKS...

daylinky1.png

gjr80

unread,
Sep 20, 2023, 6:03:17 AM9/20/23
to weewx-user
On the face of it that looks OK, but it would help to see the entire [ImageGenerator] stanza in skin.conf.

Gary

Remy Lavabre

unread,
Sep 22, 2023, 4:46:40 AM9/22/23
to weewx-user
Hi.
Skin.conf :

#Histogrammes horaires électricité LINKY
        [[[daylinky1]]]
            yscale = None, None, 1
            plot_type = bar
            unit = watt_hour
            [[[[electricityLinky]]]]
                chart_fill_colors = Red
                color = Red
                aggregate_type = sum
                aggregate_interval = hour
                label = Linky (total horaire)

#Histogrammes cumul horaires électricité LINKY
        [[[daylinky2]]]
            yscale = None, None, 1
            plot_type = bar
            unit = kilowatt_hour
            [[[[electricityLinky]]]]
                chart_fill_colors = Red
                color = Red
                aggregate_type = cumulative
                aggregate_interval = hour
                label = Linky (cumul sur les 24 dernières heures)

gjr80

unread,
Sep 22, 2023, 5:19:41 AM9/22/23
to weewx-user
chart_fill_colors is a config option that applies to all lines/bars not individual lines/bars. Try moving chart_fill_colors to be under the main plot config rather than under an individual line/bar config, eg:

#Histogrammes horaires électricité LINKY
        [[[daylinky1]]]
            yscale = None, None, 1
            plot_type = bar
            unit = watt_hour
            chart_fill_colors = Red
            [[[[electricityLinky]]]]

                color = Red
                aggregate_type = sum
                aggregate_interval = hour
                label = Linky (total horaire)


If you want to specify the colour for an individual bar use fill_color instead, eg:

#Histogrammes horaires électricité LINKY
        [[[daylinky1]]]
            yscale = None, None, 1
            plot_type = bar
            unit = watt_hour
            [[[[electricityLinky]]]]
                color = Red
                fill_color = Red

                aggregate_type = sum
                aggregate_interval = hour
                label = Linky (total horaire)


Gary

Remy Lavabre

unread,
Sep 22, 2023, 11:33:53 AM9/22/23
to weewx-user
Hello Gary and thank you again for your response.

1/If I put the option chart_fill_colors = Red in [[[daylinky1]]] as you suggest, it curiously blocks everything. My histogram is not generated but also the following ones from skin.conf.
If I replace chart_fill_colors = Red in the [[[[electricityLinky]]]] section EVERYTHING works normally again.

2/ Well seen for the fill_color = Red option placed in the [[[[electricityLinky]]]] section. This now generates red histograms for me.
If I set color = Red the title changes to red but also the edges of the histograms ! :-(

The weewx documentation states:
"chart_line_colors: Each chart line is drawn in a different color. This option is a list of those colors. If the number of lines exceeds the length of the list, then the colors wrap around to the beginning of the list. Optional. In the case of bar charts, this is the color of the outline of the bar. Default is #0000ff, #00ff00, #ff0000.
Individual line color can be overridden by using option color."

Oddly enough, the "chart_line_colors = Black" option placed in the [[[[electricityLinky]]]] section produces no effect...

On the other hand, if I do not stipulate color = Red, I have the borders of the histograms which are a different color from red (blue).

I do not understand why !

Without option color = Red :
daylinky1.png


with options color = Red and chart_line_color = Black :

daylinky2.png

gjr80

unread,
Sep 22, 2023, 10:41:35 PM9/22/23
to weewx-user
There is a bug in WeeWX that may cause chart_fill_colours to fail in some circumstances if only a single colour name is specified. The bug will be fixed in due course, but in the interim if you either specify a second colour (eg chart_fill_colors = Red, Blue) or terminate the a single entry with a comma (eg chart_fill_colors = Red,) it should generate the plot as expected.

Same thing applies to chart_line_colors.

Gary

Remy Lavabre

unread,
Sep 24, 2023, 11:09:28 AM9/24/23
to weewx-user
Hello Gary,

No sorry, it doesn't work anymore.
See below :

#Histogrammes horaires électricité LINKY
        [[[daylinky1]]]
            yscale = None, None, 1
            plot_type = bar
            unit = watt_hour
            [[[[electricityLinky]]]]
                color = Red
                fill_color = Red
                chart_line_colors = Black,Blue

                aggregate_type = sum
                aggregate_interval = hour
                label = Linky (total horaire)

daylinky1.png
and idem with "chartl_line_colors = Black,"

gjr80

unread,
Sep 24, 2023, 7:24:40 PM9/24/23
to weewx-user
As with chart_fill_colors, chart_line_colors is an option setting that is applied to a chart, not individual 'lines'. You have chart_line_colors set under the 'line' [[[[electricityLinky]]]] so it is effectively ignored (chart_line_colors has no meaning when used under a 'line'). If you want to specify a list of colours (be it fill colours or line colours) you need to set chart_xxxxx_colors under the plot definition (in this case [[[daylinky1]]]), if you want to specify individual fill colours or line colours then you need to set xxxx_color under each 'line' definition (in this case [[[[electrictyLinky]]]]). You can mix and match if you want, eg specify chart_fill_colors for a plot and specify line_color for each 'line' in the plot (or vice versa), you just need to make sure the option settings are put in the correct place/level.

Gary 

Reply all
Reply to author
Forward
0 new messages