Connecting SQLite extension and ChartMaker extension

Hi all, I try to pass the result of a SELECT action on a SQLite db to pass on to the DrawLineGraph method of Chartmaker method (I know both extensions are not on the supported list of AppInventor). The SELECT command on the db results in a list like this:
[[03/07/2020, 67.4],
[04/07/2020, 69.2]]
However passing that to the DrawLineGraph I always get the message the format is not conform the YailList:
"java.util.ArrayList cannot be cast to com.google.appinventor.components.runtime.util.YailList"
Not familiar with YailLists but if I understand right it means the elements should contain text, something like this:
[["07:15:25 15-6-2020", "75.5"],
["07:16:26 16-6-2020", "76.6"]]

Seems strange to me since their sample works with just using fix math numbers to make up the list. That makes up something like this:
((1 19 87)(4 10 45))
Is there a proper way to pass on the table from an SQLite to the methods of ChartMaker?
Is there a proper way to convert the table to a Yail table? I tried about every option in the Text block but fail to convert it in a proper way. I'm reluctant to iterate over every element in the list and convert it to text in another list.
Any help or tips? Thanks a bunch in advance!

are you

  1. developing your own extension based on these 2 extensions or
  2. are you using these 2 extensions in App Inventor and trying to pass values from the slite extension to the chartmaker extension?

for 2) It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Thanks for your reply. I'm a 2 (junior in app creating, just happen to know one another of programming). Not sure how detailed I should be, but here it is: a simple "collect data in a db, show the results in a graph" - example:


Thanks!

that extension returns the data as csv table? and if yes, you have to convert that csv table into a list of lists, you can use the list from csv table block for that

Unbenannt
use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun
PS: I changed the category of this thread to MIT App Inventor Help


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

See here for info about the values section
https://groups.google.com/d/msg/mitappinventortest/S3tw7gSGE8A/D8DFWJQrBAAJ

Thanks for your help. I placed that example with a CSV file next to it, and that works fine. You can also see the parsing works fine. In the DB example the parsing results in this:
Do It Result: [["[[04/07/2020", "76.8]", "[04/07/2020", "78.5]]"]]
It fails to extract the square brackets and takes them as a part of the value. That's most likely where it fails. Just not sure how to fix that. Tried a couple of replace [ with ( brackets but nothing really worked.

In your procDrawResultsDB procedure global rsltDB already looks like a list so it shouldn't need to be converted using list from csv table? However it may only "look" like a list. You may need a block from the web component to convert the "json" to a list. One of these:

image

Thanks for your reply! Indeed is already a list. The return of the "SELECT" SQL command passes the "Is list" check. If I pass that list directly to the DrawGraphLine I get the YailList error. Although the format looks exactly the same as if I create a list with fixed numbers (like the example here). Whatever conversion I have tried on the rsltDB list before passing it to the DrawGraphLine block, they all make it worse or fail and make the app crash.None of the web blocks to convert to JSON worked either

.
I probably could go and save the results of the "SELECT" SQL command in a file and then read that file, but that would just be working around the issue here.

I have just run a test and I believe the Chartmaker extension is not working anymore (android 9 genymotion) - let me try with gviz..

OK this works for companion app, we cut out the middle man and go straight to google charts:

BLOCKS

HTML

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      
      var rawdata = window.AppInventor.getWebViewString();
            
      function drawChart() {
				
		var heading = rawdata.split("||")[1];
		var xaxis = rawdata.split("||")[2];
		var yaxis = rawdata.split("||")[3];
		var chtdata = eval("["+rawdata.split("||")[0]+"]");
				
        var data = google.visualization.arrayToDataTable(chtdata[0]);
                
        var options = {
          title: heading,
          hAxis: {title : xaxis},
          vAxis: {title : yaxis},
          legend: { position: 'none' }
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart'));

        chart.draw(data, options);
      }
    </script>
    <script>
    
    </script>
  </head>
  <body>
    <div id="chart" style="width: 300px; height: 200px"></div>
  </body>
</html>

SCREEN
image

AIA
linecharttest.aia (12.4 KB)

PLEASE NOTE: If you see the heading labels in the values csv, they have single quotes. These are important, and you will need to put them into your list (use replace item block). I have used two bars (||) as the delimiter in the text sent via webviewstring. I recommend you set your dates as strings as well.

https://developers.google.com/chart/interactive/docs/gallery/linechart

Wow nice, thanks for your help. I'll give it a go. Would be nice though if AppInventor has an extension like ChartMaker, that would make this example functional offline too.

More than one way to skin a cat: