Posts

Showing posts with the label BarChartView in Sketchware

BarChartView in Sketchware

Image
In Sketchware project, if you have a List Map containing a key with numerical values, it can be displayed in a graph form using the BarChartView code created by me. Follow the steps given below to understand how to use it. 1. Create a new page graph.xml to display the bar chart. 2. On the page containing the List Map, add a button to move to GraphActivity.java . In the event of Button onClick , save List Map in Intent put Extra key "list" by converting it to Json String and then move to GraphActivity.java . 3. In  graph.xml  add a LinearV  linear1 . 4. In  GraphActivity.java  add a ListMap  listmap . 5. In  onCreate  event use blocks to get json string in Intent extra key "list", and convert it to listmap . Then use codes to display this ListMap in BarChartView. The code used in add source directly block is BarChartView chart = new BarChartView(this, listmap, "totalConfirmed", "loc"); linear1.addView(chart); Here 'l...

BarChart in Sketchware android project

Image
In Sketchware, to create an app in which data with numerical values can be added and viewed as a Bar chart, follow the steps given below. 1. Create a new project in Sketchware. 2. In main.xml add two Buttons button1 and button2 . Set text of button1 to 'Add' and text of button2 to 'Bar Chart'. Also add a ListView listview2 . 3. Create a CustomView items.xml and add two TextViews in it  textview1 and  textview2 . 4. Select items.xml as CustomView of listview2 . 5. In MainActivity.java , add a Shared Preferences component sp:sp , a Dialog component dialog_add , and an Intent component i . 6. Add a Map variable map , three String variables jsondata , label and value , and a ListMap maplist . 7. In onCreate event use blocks to get data from shared preferences to maplist and display it in ListView. 8. In onBindCustomView event, display the data from maplist in the TextViews in CustomView items.xml. 9. Create a CustomView d...