{"id":29601,"date":"2016-11-16T15:04:15","date_gmt":"2016-11-16T15:04:15","guid":{"rendered":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/?page_id=29601"},"modified":"2020-12-15T17:25:13","modified_gmt":"2020-12-15T17:25:13","slug":"creating-dynamic-buttons-in-instantatlas-html-reports","status":"publish","type":"page","link":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/en\/welcome\/support-articles\/creating-dynamic-buttons-in-instantatlas-html-reports\/","title":{"rendered":"Creating Dynamic Buttons in InstantAtlas HTML Reports"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>This article describes how to create dynamic buttons in HTML Edition Templates which will dynamically change to display different text after they have been clicked.<\/p>\n<p>This is particularly useful if you are maximising the space in your dynamic report by having one (or more) components on top of each other, therefore requiring a button to switch between these different components and would\u00a0prefer to have different text to display in the button to show the user what chart component will be displayed when the button is clicked. It is assumed\u00a0that you have read the InstantAtlas Designer section of the InstantAtlas Desktop User Guide prior to reading this document.<\/p>\n<p>The following example demonstrates how to create a dynamic button which\u00a0will display \u2018Time Series\u2019 when the Bar Chart is displayed, and \u2018Bar Chart\u2019\u00a0when the Time Series Chart is displayed.<\/p>\n<h2><b>Config.xml configuration<\/b><\/h2>\n<p>As you can see in below we have the Single Map HTML Template which has been configured to display the Time Series Chart and Bar Chart on top of each other.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/SingleMap.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/SingleMap.jpg\" alt=\"\" class=\"alignnone size-full wp-image-34078\" width=\"1381\" height=\"815\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/SingleMap.jpg 1381w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/SingleMap-300x177.jpg 300w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/SingleMap-1024x604.jpg 1024w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/SingleMap-768x453.jpg 768w\" sizes=\"auto, (max-width: 1381px) 100vw, 1381px\" \/><\/a><\/p>\n<p>In the Designer, we shall now add in our first button called \u2018Bar Chart\u2019 and position it near the Bar Chart and Time Series Chart as seen below.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/DesignerFirstButton.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/DesignerFirstButton.jpg\" alt=\"\" class=\"alignnone size-full wp-image-34080\" width=\"291\" height=\"255\" \/><\/a><\/p>\n<p>We shall now insert our second button called \u2018Time Series\u2019 and change its\u00a0position so that they are exactly on top of each other. This will enable the\u00a0&#8216;Time Series\u2019 button to be displayed on start up.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/twoBottons.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/twoBottons.jpg\" alt=\"\" class=\"alignnone size-full wp-image-34082\" width=\"466\" height=\"354\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/twoBottons.jpg 466w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/twoBottons-300x228.jpg 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/a><\/p>\n<p>As the \u2018Time Series\u2019 button is visible on start up then we would not like the\u00a0Time Series Chart to be visible on start up, but have the Bar Chart visible\u00a0on start up instead. Therefore we need to make sure that in the properties\u00a0of the Time Series Chart, \u2018Visible At Startup?\u2019 is unticked.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesProperties.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesProperties.jpg\" alt=\"\" class=\"size-full wp-image-34083 alignleft\" width=\"256\" height=\"284\" \/><\/a><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesProperties.jpg\"><\/a><\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesChartHidden.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesChartHidden.jpg\" alt=\"\" class=\"size-full wp-image-34084 alignleft\" width=\"430\" height=\"290\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesChartHidden.jpg 430w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesChartHidden-300x202.jpg 300w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Now we need to insert the javascript function for the buttons, this will\u00a0activate the custom javascript code.\u00a0Select the Time Series button, and go to the Links tab, in the URL box type\u00a0\u2018javascript:toggleTSandHideTSbutton\u2019.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesFunction.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/TimeSeriesFunction.jpg\" alt=\"\" class=\"alignnone size-full wp-image-34086\" width=\"294\" height=\"172\" \/><\/a><\/p>\n<p>Select the Bar Chart button, and go to the Links tab, in the URL box type\u00a0\u2018javascript:toggleTSandUnhideTSbutton\u2019.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/BarChartFunction.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/BarChartFunction.jpg\" alt=\"\" class=\"alignnone size-full wp-image-34085\" width=\"293\" height=\"176\" \/><\/a><\/p>\n<h2><b>Custom.js configuration<\/b><\/h2>\n<p>The custom.js file is the file that you will insert your customisable code to\u00a0trigger the correct button to display and toggle the charts. This file will be\u00a0located in your report folder. In its unedited state it will look similar to the image below.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons8.png\" alt=\"Figure 8\" class=\"size-full wp-image-29861\" width=\"894\" height=\"578\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons8.png 894w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons8-300x194.png 300w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons8-768x497.png 768w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/a><\/p>\n<p>Copy and paste the following code between the curly brackets of the <em>iaOnReportComplete = function(report) <\/em>function (Line 34):<\/p>\n<pre>toggleTSandHideTSbutton = function() {\r\ndocument.getElementById('ia-widget-___user_extra_48').style.visibility='hidden';\r\niaToggle('timeSeries');\r\n};\r\n\r\ntoggleTSandUnhideTSbutton = function() {\r\ndocument.getElementById('ia-widget-___user_extra_48').style.visibility='visible';\r\niaToggle('timeSeries');\r\n};\r\n<\/pre>\n<p>The first part of this code, which is assigned to the Time Series button, states that when clicked it hides \u2018___user_extra_48\u2019 and toggles the Time Series Line Chart.<\/p>\n<p>The second part of this code, which is assigned to the Bar Chart button, states that when clicked it shows \u2018___user_extra_48\u2019 and toggles the Time Series Line Chart.<\/p>\n<p>\u2018___user_extra_48\u2019 is the ID of the \u2018Time Series\u2019 button and \u2018timeSeries\u2019 is the ID of the Time Series Line Chart.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2015\/08\/image27.png\" alt=\"image27\" class=\"alignnone size-full wp-image-1701\" width=\"22\" height=\"20\" \/>\u00a0Please note that the button ID may be different in your report. \u00a0Right click on the button in the browser window and choose &#8216;inspect element&#8217; to check on the ID.<\/p>\n<p>The custom.js file with the new code should now look as follows.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/customjs.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/customjs.jpg\" alt=\"\" class=\"alignnone size-full wp-image-34087\" width=\"892\" height=\"704\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/customjs.jpg 892w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/customjs-300x237.jpg 300w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2020\/12\/customjs-768x606.jpg 768w\" sizes=\"auto, (max-width: 892px) 100vw, 892px\" \/><\/a><\/p>\n<h2><b>Advanced<\/b><\/h2>\n<p>You can apply this method to other components by changing the code in the custom.js file to pick up the different components of the dynamic report. To do this you will need to know the ID\u2019s of the different components. In the previous example these were \u2018___user_extra_45\u2019 which was the ID of the \u2018Time Series\u2019 button and \u2018barChart\u2019 which is the ID of the Bar\u00a0Chart. The ID\u2019s of the different components can be found in the config.xml\u00a0file opened in a text editor, for example \u2018id=\u201ddataExplorer\u201d\u2019 as seen below.<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons10.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons10.png\" alt=\"Figure 10\" class=\"size-full wp-image-29911\" width=\"1249\" height=\"880\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons10.png 1249w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons10-300x211.png 300w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons10-768x541.png 768w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons10-1024x721.png 1024w\" sizes=\"auto, (max-width: 1249px) 100vw, 1249px\" \/><\/a><\/p>\n<p>The ID\u2019s of your user added buttons will be found at the end of the config.xml file:<\/p>\n<p><a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons11.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons11.png\" alt=\"Figure 11\" class=\"size-full wp-image-29921\" width=\"1259\" height=\"904\" srcset=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons11.png 1259w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons11-300x215.png 300w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons11-768x551.png 768w, https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-content\/uploads\/sites\/31\/2016\/09\/dynButtons11-1024x735.png 1024w\" sizes=\"auto, (max-width: 1259px) 100vw, 1259px\" \/><\/a><\/p>\n<p>Replacing these ID\u2019s in the code from section &#8216;custom.js configuration\u2019 and modifying your functions will enable you to create dynamic buttons and toggle the visibility of other chart components.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction This article describes how to create dynamic buttons in HTML Edition Templates which will dynamically change to display different text after they have been clicked. This is particularly useful if you are maximising the space in your dynamic report by having one (or more) components on top of each other, therefore requiring a button &hellip; <a href=\"https:\/\/help.instantatlas.com\/instantatlas-desktop\/en\/welcome\/support-articles\/creating-dynamic-buttons-in-instantatlas-html-reports\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Creating Dynamic Buttons in InstantAtlas HTML Reports<\/span><\/a><\/p>\n","protected":false},"author":22,"featured_media":0,"parent":27601,"menu_order":40,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-29601","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/pages\/29601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/comments?post=29601"}],"version-history":[{"count":0,"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/pages\/29601\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/pages\/27601"}],"wp:attachment":[{"href":"https:\/\/help.instantatlas.com\/instantatlas-desktop\/wp-json\/wp\/v2\/media?parent=29601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}