request for sample code draw a graph/chart

Hi, does anyone have some sample code for drawing a chart or graph from an array/storage (time vs height)?

Thanks

  • the oldest is drawn outside the bounds of the target.  The border would have to be redrawn or cached separately.  Its all a cpu vs memory tradeoff.  Take up more memory so you can cache operations and take less cpu or don't store things to take up less memory but use more cpu recomputing things.  Using more CPU hurts performance but on most garmins this is probably more noticeable in the battery power it takes

  • I see there is DC.setClip() function that can mark a region that would not be redrawn. This could be used with buffered bitmap. Anyways this tradeoff (cpu vs memory) might not be ideal everywhere - Insintct 2 has quite low memory. Anyways - I agree it would be nice to have some curated classes that experienced developers maintain to make it easier for the community.

  • You want to be careful with setClip and onUpdate, as you don't want to block things like current time from getting updated on the screen.

  • Anyways - I agree it would be nice to have some curated classes that experienced developers maintain to make it easier for the community.

    I feel like good generic libraries aren't really possible as they take up too much memory making them generic but that there could be code that is better curated then the current here is the source code to a bunch of apps.  In that some of that code could be optimized or better commented for someone coming behind why its structured the way it is. So the point is for others to reuse the code and not for the app itself.  You almost have to use Prettier Monkey C to be able to make the code more readable but not too unoptimized:
    marketplace.visualstudio.com/items

    Anyways this tradeoff (cpu vs memory) might not be ideal everywhere - Insintct 2 has quite low memory.

    Which is why having a library of the kind where a functions is implemented in different ways depending on the tradeoff wanted would be useful.  If possible use annotations so the right choice is made but for the rest can just copy and paste what you want into your code.  If you don't have the memory, use more cpu, if you do have the memory, use more memory.   

  • You're talking about developing a barrel.  Not something as part of Monkey C itself.  Anyone can write a barrel and publish it.

    Here's the Garmin Github for barrels: https://github.com/garmin/connectiq-apps/tree/master/barrels

    You'll probably find it a bit of overkill if you just want to draw a single graph after you do a couple graphs.  It's really not that hard.

  • Nice! Barrels have same issue with resource consumption, since they are just external imports, right?

  • Not really external.  When you create a ,barrel, all that is is a zip of the barrel project, and it gets unzipped and compiled when the main app is compiled.  They are a good way to share code.

  • I know this comment is 2 years old but I got to this conversation while looking for examples of exactly what you explain. I want to plot something after computations and if possible only do the last part and shift everything to the left.

    Do you have any examples of this available? I am still searching but this conversation popped up as one of the first results so I am afraid of not finding any.