Displaying plots or graphs in Cinder

Hi all,

Does anyone know of a good way to display a scientific-style plots in Cinder? I am thinking, for example, of displaying financial data as a time series, or displaying the real-time output from a sensor device as a graphical plot.

There may be a Cinder block or similar out there that would help with this, but I can’t seem to find one.

Kind regards,

Dave

Hi Dave,

for relatively static data, you’d might want to have a look at the Cairo samples. They allow you to create high quality 2D graphics.

For dynamic data, I’d suggest to create a VboMesh using a GL_LINE_STRIP primitive. Then you’d simply update the 2D vertices and draw them as a gl::Batch. As far as I know, there are no ready-made samples that do exactly this, but you can find something similar in this sample as well as in the even more appropriate VboMesh sample.

-Paul

In addition to Cairo, you could use Shape2d if you just want a simple graph with no curves or fanciness.

Something like this should work:

    // in header
    std::vector<float> mData;
    Shape2d mGraph;

    // in setup or update
    mGraph.clear();
    mGraph.moveTo(0, 0);
    
    for (int i = 0; i < mData.size(); i++) {
        mGraph.lineTo(vec2(i, -mData[i]));
    }
    mGraph.lineTo(0, 0);
    mGraph.close();

    // in draw
    gl::ScopedColor c(1, 1, 0);
    gl::drawSolid(mGraph);

Thanks both for your helpful answers.

Kind regards,

Dave