Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
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.
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
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.
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;
});