Plotly is a very rich and powerful Python library for the generation of interactive charts: https://plotly.com/graphing-libraries/
The output of Plotly, in this case, is a html string that is loaded to a WebView.
As a first example of Plotly I'm demonstrating how to visualize hierarchical data:
The (outdated) data source: https://gist.github.com/tiagodealmeida/0b97ccf117252d742dddf098bc6cc58a
Dependencies:
The data is loaded into a 2d table - a list of lists:
It is then converted to Python Dataframe and the html is generated by the provided code.
The Path parameter specified the hierarchical order. As we don't have a single root node in the data it is added with the Constant method:
Same example in a server configuration: https://www.b4x.com/android/forum/threads/pybridge-server-online-charts-with-plotly.167983/
The output of Plotly, in this case, is a html string that is loaded to a WebView.
As a first example of Plotly I'm demonstrating how to visualize hierarchical data:
The (outdated) data source: https://gist.github.com/tiagodealmeida/0b97ccf117252d742dddf098bc6cc58a
Dependencies:
B4X:
pip install plotly
pip install "plotly[express]"
pip install pandas
B4X:
Dim Data As List = B4XCollections.CreateList(Null)
For Each c As Map In RawData
Dim Country As String = c.Get("countryName")
Dim Population As Long = c.Get("population")
Dim Continent As String = c.Get("continentName")
Data.Add(Array(Continent, Country, Population))
Next
The Path parameter specified the hierarchical order. As we don't have a single root node in the data it is added with the Constant method:
B4X:
Dim Path As List = Array(px.Run("Constant").Arg("World"), "Continent", "Country")
Same example in a server configuration: https://www.b4x.com/android/forum/threads/pybridge-server-online-charts-with-plotly.167983/
Attachments
Last edited: