Dashboards & Visualizations

How do I make a custom visualization resize to fill the panel?

sillingworth
Path Finder

How do I make a custom visualization resize to fill the panel, like the built-in visualizations do?

I've gone through this tutorial but I have only been able to hardcode the size. https://docs.splunk.com/Documentation/Splunk/6.5.3/AdvancedDev/CustomVizTutorial

0 Karma

sduff_splunk
Splunk Employee
Splunk Employee

You need to overwrite the reflow function. This is called when ever the visualisation is resized. You can get the new dimensions with the following code.

            reflow: function() {
                this.$el = $(this.el);
                var container = this.$el[0];
                var rect = container.getBoundingClientRect();
                // rect.width, rect.height
            }

For the example, you would probably need to redraw the SVG, so perhaps call the following with the new dimensions

            // SVG setup
            var svg  = d3.select(this.el).append('svg')
               .attr('width', width)
               .attr('height', height)
               .style('background', 'white')
               .append('g')
               .attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')');
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...