QCustomPlot Discussion and Comments

Replacing Value for the same key in GraphReturn to overview

I am adding data by the following command

chart->graph(graph_index)->addData(1234,888);

If I want to update the value for 1234 to 9999 , how do I do it?

you may wanna use

void QCPGraph::setData(QSharedPointer<QCPGraphDataContainer> data);

in that container you can search for the position (if you don't know it)

const_iterator QCPGraphDataContainer::findBegin(double sortKey, bool expandedRange=true) const;

since that position is const you will have to use it to calculate the index, the item can then be set via

begin() + index

since that is the only way to get at the item in an non-const way.

PS: is it me or are you just to lazy to look at the header ...

You can easily remove old data and than add new data to graph.

chart->graph(graph_index)->data()->remove(1234);
chart->graph(graph_index)->addData(9999, 888);

Ermans looks nice and simple. The main difference is that my solution sketch can overwrite existing values, potentially causing much less activity, esp depending on where the element is located. That is why I esp. tried to find a way that an existing value could be overwritten.

PS: I think the add should be

chart->graph(graph_index)->addData(1234,9999);