I have a chart where I am using a Hierarchy as Category Axis. I want to capture changes in that Axis (Hierarchy) to a Property Control. Is there a way to do this ?
Sounds interesting 🙃
Well , Let's start doing it !
- Add a Input field property enclosed in a span like below. Code in red is optional based on whether you need to display document property on not.
<span id='AxisTracker' style='display:none;'>
<SpotfireControl id="635a7ae743a14feb865833e75f3e9b4d" />
</span> - Add below JavaScript to capture changes. Here code in red indicates the possible states of Hierarchy Axis of interest
function updateProperty(){
$('.sf-element-text-box').each(function(index){
//console.log($(this).text());
switch($(this).text()){
case "Geo (Region)":
case "Geo (State)":
case "Geo (City)":
console.log($(this).text());
$('#AxisTracker input').val($(this).text()).blur()
break;
}
});}
setInterval(updateProperty,500) - This is pretty much all 🤓
Using this approach helps in tracking changes to the Axis and we can trigger IronPython code as well on Document property change.