Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot remove pie chart entries on Android #3262

Open
2 of 8 tasks
ewpatton opened this issue Nov 26, 2024 · 6 comments
Open
2 of 8 tasks

Cannot remove pie chart entries on Android #3262

ewpatton opened this issue Nov 26, 2024 · 6 comments

Comments

@ewpatton
Copy link
Member

Describe the bug

Affects

  • Designer
  • Blocks editor
  • Projects Explorer
  • Companion
  • Compiled apps
  • Buildserver
  • Debugging
  • Other... (please describe)

Expected behavior

Trying to remove an existing entry in the pie chart gives the following error:

java.lang.NumberFormatException: For input string: "cherry"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at com.google.appinventor.components.runtime.ChartData2D$2.run(ChartData2D.java:120) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 

Steps to reproduce

  1. Add a Chart and ChartData2D to a project
  2. Populate the ChartData2D with some values via ElementsFromString, e.g., "apple,2,blueberry,3,cherry,5
  3. Add a ChartData2D.RemoveEntry block to the block workspace to remove ("cherry",5) and use "Do It" to perform the behavior
@d1vyanshu-kumar
Copy link
Contributor

Hello @ewpatton,
I'm a new MIT App Inventor contributor and tried to replicate the issue. I followed the steps mentioned, but when I click on "Do It," the option is disabled. I'm not sure why this is happening. I can share a screenshot if that helps

Screenshot 2024-12-10 at 2 08 20 PM Screenshot 2024-12-10 at 2 08 49 PM

@SusanRatiLane
Copy link
Contributor

Hello @ewpatton, I'm a new MIT App Inventor contributor and tried to replicate the issue. I followed the steps mentioned, but when I click on "Do It," the option is disabled. I'm not sure why this is happening.

Do you have the app loaded on the Companion, either on a physical device or emulator? Do It requires access to the Companion to work.

@ShreyashN16
Copy link

Hello everyone,

I wanted to provide additional clarification and confirm the steps I followed:

I replicated the issue using the latest version of the Companion on an Android device.
After populating ChartData2D with ElementsFromString and attempting to remove an entry (e.g., "cherry", 5), the app throws a NumberFormatException error.
It appears that the issue stems from the label ("cherry") being parsed as a numeric value.
Suggested Fix:

Update the ChartData2D.RemoveEntry logic to correctly distinguish between numeric values and string labels.
Implement a safeguard to prevent non-numeric labels from being parsed as floats.
Let me know if there's any additional debugging or testing you'd like me to perform.

Thank you!

@ewpatton
Copy link
Member Author

ewpatton commented Jan 5, 2025

@ShreyashN16 That sounds roughly correct but in theory people may still want to be able to use numeric labels, they will just have to be converted to strings first.

@ShreyashN16
Copy link

@ewpatton
You're absolutely right—numeric labels can be useful, especially when dealing with datasets. If the system mandates string labels, users can convert numeric labels to strings before adding them to the chart. For instance,
in Java:

int numericLabel = 123;
String label = Integer.toString(numericLabel;
// Add the label to the chart

This approach maintains flexibility while conforming to the current requirements. It might also be worth considering an enhancement where the system internally handles such conversions for better usability.

@cindyloo cindyloo self-assigned this Jan 23, 2025
@cindyloo
Copy link

reproduced:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants