B4J Question How to access Javascript's Variable

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

Following is HTML code. Could i use the variable of "graphic" in B4J ?

B4X:
var container = document.getElementById('container');

    // Create a graphic instance over the container
    var graphic = archer.create(container);

    // Tell the graphic where assets (e.g. images) are located
    graphic.document.setAssetRoot(assetUrl);

    // Load graphic and configuration
    graphic.loadUrl(graphicUrl, configUrl);

    // Wait until files are loaded
    graphic.on('ready', function () {

        // Make graphic fit into container bounds
        graphic.view.zoomToFit();

        // Enable zoom / pan with mouse
        graphic.view.enableMouse(true, true);

        // Set variable values
        graphic.setValue('TempUnit', false);
        graphic.setValue('TempValue', '1.2');

        // Add event listeners

    });
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I use following code. It's OK.

B4J
B4X:
ws.RunFunction("HmiSetValue",Array As Object("TempValue",s1))
HTML
B4X:
function HmiSetValue(na,va) {
    graphic.setValue(na,va);
};

function HmiGetValue(na) {
    return graphic.getValue(na);
};

ARCHER
VALUE DRIVEN GRAPHICS
Create dynamic graphics for websites, apps, HMI or IoT projects
 
Upvote 0
Top