Coder Social home page Coder Social logo

Comments (6)

jposada202020 avatar jposada202020 commented on June 12, 2024 1

Hiya, please take a look in 0.13.0 including an updating function for filled bars.

from circuitpython_uplot.

DJDevon3 avatar DJDevon3 commented on June 12, 2024

It appears to be running out of colors as the color sequence is always the same. Is there a way to have the bar graph color array loop so it doesn't run out? There seems to be 11 colors in the index and once it refreshes 3 times it runs out of colors in the index. I'm pulling 5 colors per refresh and on the 3rd refresh it only displays 1 bar because it runs out of colors. So it's not an a or b index issue it's a color index issue.

from circuitpython_uplot.

jposada202020 avatar jposada202020 commented on June 12, 2024

Thank you, yes, that was the case. Please see https://github.com/jposada202020/CircuitPython_uplot/releases/tag/0.11.2
just FYI according to my test you will run out of memory in the 49 refresh at least with 5 bars. The library could be modified to have a function to update the bars with a specific function a preserve memory, and run ideally forever, but will require more development. If you are happy to wait, I am happy to code it :)

from circuitpython_uplot.

DJDevon3 avatar DJDevon3 commented on June 12, 2024

Definitely better. Been running it for about an hour every 30 seconds and haven't hit the limit yet. If you say it should get about 50 attempts before running out of ram then that's 50x30= 25 minutes. I've been running it for well over an hour. I'm using an unexpected maker S3 which has 8MB of psram, it might take a little longer.

I have noticed some odd artifacts though starting on the 3rd refresh with the first two bars either skipped or black.

ubar(plot, a, b, 0xFF1000, True)

skipping_or_black_graph

Then the next get request after that one I get this.

skipping_or_black_graph_overdraw

The cycle repeats itself infinitely so far every 3rd or 4th refresh after that with the black bars and red overdraw. The tops of the graphs aren't displaying correctly to correlate with the values. Quite an odd effect.

Things seem to still overdraw instead of removing/replacing the graph. I have no idea how it works just showing you the results.
IMG_1081_2

from circuitpython_uplot.

DJDevon3 avatar DJDevon3 commented on June 12, 2024

After about 2 hours becomes unrecognizable and not very useful to say the least. There's definitely some room for improvement.

IMG_1082_2

from circuitpython_uplot.

jposada202020 avatar jposada202020 commented on June 12, 2024

Indeed, you are creating new barplot instances one on top of the other so this is expected, the library auto-scale the limits so sometimes previous bar are hidden and sometimes they are not. This will be the normal behaviour unless a new update function is created in the library to update the original bars. A hack, is to remove the bar from the group as in the following example:

# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya, DJDevon
#
# SPDX-License-Identifier: MIT

import board
from circuitpython_uplot.uplot import Uplot, color
from circuitpython_uplot.ubar import ubar
import time

# Setting up the display
display = board.DISPLAY

# Configuring display dimensions
DISPLAY_WIDTH = 480
DISPLAY_HEIGHT = 320

# Defining the plot
plot = Uplot(
    0,
    0,
    DISPLAY_WIDTH,
    DISPLAY_HEIGHT,
    background_color=color.BLACK,
    padding=10,
    box_color=color.BLACK,
)

# Dummy data to plot
activities_latest_heart_value = [55, 20, 25, 30, 35, 10]
a = ["a", "b", "c", "d", "e", "f"]
number_of_bars = len(activities_latest_heart_value)


multiplier = 1
# Showing the plot
display.show(plot)

for i in range(20):
    activities_latest_heart_value_changed = [
        j + multiplier for j in activities_latest_heart_value
    ]
    ubar(
        plot,
        a,
        activities_latest_heart_value_changed,
        0xFF1000,
        True,
        color_palette=[
            0xFF1000,
            0x00FF00,
            0x0000FF,
            0xFFFF00,
            0x00FFFF,
            0x123456,
        ],
    )

    multiplier += 1
    time.sleep(1)
    for _ in range(number_of_bars):
        plot.pop()


from circuitpython_uplot.

Related Issues (15)

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.