How to a graph on Android webView to set data inside of JSON file among JS Script tags to provide coordinates to draw graph


I am working on Android Studio to plot a graph to indicate (X, Y, Z) points.
In order to plot’s graph with Android’s variables such as “int x,y,z =0;” I have to get the variable from Android/Java into’s Javascript codes inside, and directly into I couldn’t make this happen, and I need a help to set variables from Android to to draw a graph on Android’s webView.

My environment on Android’s MainActivity.Java:

WebView myWebView = (WebView)findViewById(;
myWebView. * other necessary settings*

myWebView.loadDataWithBaseURL(“file:///android_asset/”, “< html >< head>< p > codes on here< /p >
< /body>>< /html>”, “text/HTML”, “UTF-8”, null);

I prepared a working demo graph on assets folder which known by Android as android_assets as different from a regular folder, but works almost similar on some points.

Between the HTML tags, I have the graph points to be declared as x, y, z:

< html> < body>
< script id=“plot-data” type=“text/json” src=“data.json”>[{“line”: {“color”: “black”, “width”: 3}, “mode”: “dashes”, “type”: “scatter3d”,
“x”: [1, 2, 3, 4, 5],
“y”: [0, 1, 2, 3, 4],
“z”: [1, 3, 5, 7, 9]}]
< /script>
< /body>< /html>

So, how can I change “x”, “y”, “z” ingredients by be able to define from Android’s java side?
Actually I used to divide the JSON part away from tags, but this didn’t work or I couldn’t do.
I mean <script src="/aJsonData.json" …> < script> this code couldn’t be worked by me to provide from other file into it.

Also I tried inserting a “replace” function on javacript side to run from Android/Java but, this couldn’t change the Json file.

To sum up, I stuck at making graphics from providing x, y, z variables from Android/Java side into

Kind Regards.