//#####package package uk.co.metricrat.pie; //##### //#####imports import android.util.Log; import com.google.appinventor.components.annotations.SimpleFunction; import com.google.appinventor.components.runtime.AndroidNonvisibleComponent; import com.google.appinventor.components.runtime.Component; import com.google.appinventor.components.runtime.ComponentContainer; import com.google.appinventor.components.runtime.WebViewer; import com.google.appinventor.components.runtime.util.YailList; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.*; import static org.acra.ACRA.LOG_TAG; //##### public class Pie extends AndroidNonvisibleComponent implements Component { //##### private ComponentContainer container; private String filePath; public Pie(ComponentContainer container) { super(container.$form()); } //##### //##### builds pie chart @SimpleFunction(description = "Creates a pie chart from a title string and input lists of data, " + "in the WebViewer passed as the final argument. Provides for adding options") public void DrawPieChartExtended(String title, String arrayTable, WebViewer webViewer, String extraOptions) { try { String htmlCode = "\n" + " \n" + " \n" + " \n" + " \n" + "\n" + " \n" + "
\n" + " \n" + " "; File file = File.createTempFile("display", ".html"); filePath = file.getAbsolutePath(); FileWriter filewriter = new FileWriter(file); filewriter.write(htmlCode); filewriter.close(); } catch (IOException e) { Log.e(LOG_TAG, "IOException", e); } webViewer.GoToUrl("file://" + filePath); } //##### }