Git Product home page Git Product logo

Comments (4)

m-schaeffler avatar m-schaeffler commented on July 23, 2024

I'm suffering on the same issue.

from node-red-dashboard.

Martin12350 avatar Martin12350 commented on July 23, 2024

If You want, I have a "hacky" solution. But! note that this way, it refreshes the whole chart every time it gets a new value, so if You are using phone data and have a big chart with a fast refresh rate, it will chew your data out in no time.

In the chart set series to key: bar and y to key: value. You can change those names obviously.
And before the chart, create a function with this code:

var data = context.get("data") || [];

//init data if does not exist yet
if (data.length === 0)
    for (var i = 0; i < 60; i++) {
        const bar = ("0" + i).slice(-2) + ".";
        data.push({ bar, value: 0 });
    }

//update value
var index = data.findIndex(d => d.bar == msg.bar);
if (index != -1) data[index].value = msg.payload;
 
context.set("data", data);
msg.payload = data;
return msg;

It is pretty self-explanatory, but in any case, the code stores all the chart data in context, and when a message arrives with a bar value, it finds its column, updates the value, saves it in context, and sends it to the chart.

Btw. when setting the series to JSON, something similar happens - it always expects all the data and redraws the whole chart.
It would be really cool if it would just init the chart on the first time and then updates the columns depending on the payload.
Now, if any value is missing in the payload, but is specified in the series, it treats it as 0.

from node-red-dashboard.

m-schaeffler avatar m-schaeffler commented on July 23, 2024

@Martin12350 Yes: this is a kind of workaround

But it happens also with line diagrams!
If you press several times F5 to reload the page, sporadically the sequence of the lines in the legend is changed and so the colors of the lines are exchanged.

from node-red-dashboard.

Martin12350 avatar Martin12350 commented on July 23, 2024

I have also a cool proposition, but that should be probably in another thread.
When passing a new value to the chart, it could check for msg.options, where could be specified options for that specific value, such as color of the bar, color of the line, line width for the segment etc.
It is similar idea, that somebody already mentioned as advanced config (#58), but the difference is, it would be specific to the value, not the whole chart. That way we could have multicolored charts based on value, instead of the group.

from node-red-dashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.