Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

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
Alexander_Thor
Employee
Employee

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

View solution in original post

4 Replies
rbartley
Specialist II
Specialist II
Author

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

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

Alexander_Thor
Employee
Employee

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
Specialist II
Specialist II
Author

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;

        });