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

**URL:** <https://community.plotly.com/t/how-to-plot-ly-a-graph-on-android-webview-to-set-data-inside-of-json-file-among-js-script-tags-to-provide-coordinates-to-draw-plot-ly-graph/28855>\
**Category:** plotly.js\
**Created:** [September 18, 2019, 7:22am UTC](https://community.plotly.com/t/how-to-plot-ly-a-graph-on-android-webview-to-set-data-inside-of-json-file-among-js-script-tags-to-provide-coordinates-to-draw-plot-ly-graph/28855 "2019-09-18T07:22:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bay](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bay](https://community.plotly.com/u/bay)\
**Post date:** [September 18, 2019, 7:22am UTC](https://community.plotly.com/t/how-to-plot-ly-a-graph-on-android-webview-to-set-data-inside-of-json-file-among-js-script-tags-to-provide-coordinates-to-draw-plot-ly-graph/28855/1 "2019-09-18T07:22:54Z")

</div>

Hello,

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

My environment on Android’s MainActivity.Java:

> WebView myWebView = (WebView)findViewById(R.id.webview);  
> myWebView.getSettings().setJavaScriptEnabled(true);  
> myWebView. \* other necessary settings\*

> myWebView.loadDataWithBaseURL(“file:///android\_asset/”, “\< html \>\< head\>\< p \>Plot.ly 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 Plot.ly

Kind Regards.
