Search code examples
javascriptnode.jsuser-interfacenode-red

Pie chart series color are black on NodeRed


when I try to draw pie chart on nodered , colors are always black. I m using dashboard-ui node. What is the missing ? or What is best way draw pie chart on nodered ui ?

msg.payload=[{
        "series": [ "X", "Y"],
        "colors":['#8b4513','#26138b'],
        "data": [ 77,23],
        "labels": [ "Jan","mon" ]
    }];

Solution

  • There are two issues with this payload, which are stopping it from doing what you would expect:

    • the colors option is not currently supported as an input, and
    • the data must be an array of arrays, with the number of inner arrays being the same as the number of series to be shown (so in your case, an array of 1 array of y-values)

    This revised payload works for me:

        [
            {
                "series": [ "X", "Y" ],
                "data": [
                    [ 77, 23 ]
                ],
                "labels": [ "Jan", "mon" ]
            }
        ]
    

    The option to specify colors for each series would be a nice feature to add to the ui_chart node. For now, you will have to select the colors you want inside the node configuration editor. Please see the chart node's README for other examples of valid data inputs.

    -- Steve