devinaconley / arduino-plotter

An Arduino library for easy graphing on host computer via serial communication
MIT License
186 stars 31 forks source link

Print current data value along with the legend #30

Open ulkesh11 opened 5 years ago

ulkesh11 commented 5 years ago

Is there a way to print current data value (in case of a time graph) along with the legend for each plot?

phdv61 commented 5 years ago

Le 9 juil. 2019 à 00:37, vacky11 notifications@github.com<mailto:notifications@github.com> a écrit :

Is there a way to print current data value (in case of a time graph) along with the legend for each plot?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/devinaconley/arduino-plotter/issues/30?email_source=notifications&email_token=AMINDXAQEMQCMODA4RYO5RLP6O6S3A5CNFSM4H7AAYRKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G56ZTJQ, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMINDXCCUYZRSV24IPIL3Y3P6O6S3ANCNFSM4H7AAYRA.

I don’t see any reason why not.

To get continuous curves, I, modified the « graph » component. I also modified it to get fixed vertical scales, and be able to display three graphs vertically, instead of getting 2+ 2 as the present software package does.

The easiest way I think, since « Graph » gets the recent value(s) to be displayed, it to modify the display where the test of the legend appears, and replace it by a string built with the value received, and redraw it each time a new value is received.

Or you add a string somewhere and draw the value wanted converted to string , the same way the legend is.

This is what I would do. Hope it helps.

regards.

Philippe from France.

ulkesh11 commented 5 years ago

Thanks for replying Philippe

Well, I wanted to know if this is already implemented and if some parameter needs to be enables to print current value. But looks like it is not.

I have modified single line in Graph.java to do this as follows

// Draw each legend entry
for ( int i = 0; i < this.numVars; i++ )
{
    this.parent.fill( this.colors[i] );
    this.parent.text((this.labels[i] + ": " + Double.toString(this.data[this.index-1][i][1])), this.posX + this.width - 10, textPos);
    textPos += ( labelSz + labelSz/4 );
    this.parent.stroke( this.colors[i] );
}
devinaconley commented 5 years ago

@vacky11 - this feels like a useful feature. Would welcome a contribution if you open a PR with this enhancement