Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

How to check if a table rendered in an HTML dashboard before running JavaScript for a chart?

$
0
0
Please forgive my newbie questions! I have an HTML dashboard with a number of Search Managers and Visualizations. Half the visualizations are Splunk Tables, and the other half are Highcharts. I am using the data results from the table searches to also construct the Highcharts. Usually, only some of the Highcharts build, because it seems like the searches do not complete before all the chart scripts run, so there is no data for some of the charts. This is random. In the sample below, I am putting the results of the Search into an array that I use as data for a Highcharts chart. I am defining global chart settings elsewhere in the script and then combining it at the end (in the sample code) with Jquery "extend". This is all based on examples found elsewhere: // Get the result data var search1_Results = search1.data("results"); // When data changes... search1_Results.on("data", function() { var search1_Labels = []; var search1_Data = []; var search1_Data = search1_Results.data().rows; // Populate the chart (labels, data) with the search result data _.each(search1_Data, function(search1_Datum, i) { search1_Labels[i] = search1_Datum[0]; search1_Data[i] = parseInt(search1_Datum[1])+1; }); var search1_Array=[]; for(var i=0; i < search1_Labels.length; i++) { search1_Array.push({ name: search1_Labels[i], y: search1_Data[i] }); }; // Create the chart // create your data var chart_search1 = { series: [{ data: search1_Array }] }; $('#chart-search1').highcharts( $.extend(HighchartsConfig, chart_search1) ); }); So, what I am wondering is if there is a way for me to check if the Search is complete before I run the chart code? In fact, what would be greatly helpful is some way to check the existence of the rendered tables, because I'd like to strip the "table-chrome" and "table-striped" CSS classes from the tables also. So, if there is some kind of Splunk event that I can check for that says the tables are complete, then I can run the chart scripts as well as remove the classes, at the same time. All advice and help is much appreciated! Thanks in advance!

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>