Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

rbartley
Valued Contributor

ObjectId of on-the-fly visualizations

Hi all,

I have sucessfully implemented the toggle charts example posted on a Qlik blog by Yianni Ververis (see link below)

Mashup Editor - Toggle charts with jquery

This works well for visualizations that are in the underlying Sens eapp, but I am creating a number of visualizations on the fly using the create method of the Visualization API, so does anyone know how I can get the objectID of an on-the-fly visualization?

Thanks in advance.

1 Solution

Accepted Solutions
Employee
Employee

Re: ObjectId of on-the-fly visualizations

It's available on the model as a property with the name "id". Your IDs will be along the lines of MU and a 2 digit increment.

Example: Using the Qlik Visualization API - JSFiddle

4 Replies
rbartley
Valued Contributor

Re: ObjectId of on-the-fly visualizations

I managed to get this to work by creating the visualization on the radio button change event as follows:

"

$( document ).ready(function() {

    $("input[name='chart']").change(function(obj){

   

    $('#QV05').fadeOut('fast', function(){

        if(obj.target.value=="Chart1")

        {

        app.visualization.create('linechart',["Price Month","MS","=Avg([Price Eur 100KG])"],

            {

            "title":"Average price by Member State (€/100kg)"

            }

            ).then(function(vis){

                vis.show("QV05");

                });

           

        }   

        else

        {

           

        app.visualization.create('linechart',["EU Price Month","EU Price Product Name","=Avg([EU Price Eur 100KG])"],

                    {"title":"Average price by Product (€/100kg)"}

                ).then(function(vis){

                    vis.show("QV05");

                    });

           

        }

    $('#QV05').fadeIn('fast');

            });

        });

    });

"

However, I would still be interested to hear whether it is possible to get the objectid of an on-the-fly visualization.

Not applicable

Re: ObjectId of on-the-fly visualizations

Hi Richard,

You could console.log the visualization object after is created. I'm not sure if that's the "id" you are looking for though...

app.visualization.create('linechart',

     ["EU Price Month","EU Price Product Name","=Avg([EU Price Eur 100KG])"],

     {"title":"Average price by Product (€/100kg)"}

).then(function(vis){

     console.log(vis);

     vis.show("QV05");

} );

Regards,

Jose

Employee
Employee

Re: ObjectId of on-the-fly visualizations

It's available on the model as a property with the name "id". Your IDs will be along the lines of MU and a 2 digit increment.

Example: Using the Qlik Visualization API - JSFiddle

rbartley
Valued Contributor

Re: ObjectId of on-the-fly visualizations

Thanks Alexander,that worked for me. I was able to set the radio button value with the id of the on-the-fly visualization

app.visualization.create('listbox',["MS"],

        {"title":"MS"}

        ).then(function(vis){

        listboxID=vis.id;

        radioButton = document.getElementById('chart2');

          //where chart2 is the id of the second element in the radio button group

        radioButton.value=listboxID;

        });

Community Browser