JS Days 2025 is now live – Join 5,000+ devs for the premier virtual JavaScript event. Register Now

Using D3.js components in Ext JS apps

May 18, 2020 1805 Views
Show

Data visualization capabilities play a key role in modern apps. D3.js is a powerful visualization component library and can be easily integrated in Ext JS apps.

D3.js provides different component types:

  • Hierarchical Components
  • Heatmap Component
  • Custom Components

In this post, we’ll look at integrating the “d3-sunburst” and “d3-pack” component in your Ext JS app. View additional documentation on using D3 in Ext JS

Sunburst

The ‘d3-sunburst‘ component visualizes tree nodes as donut sectors with the root circle in the center.

Sunburst

1. Get hierarchical data

     	text: '/usr',
            children:[{
                text: '/X11R6'
            },{
                text: '/bin'
            },{
                text: '/doc'
            },{
                text: '/etc'
            },{
                text: '/games'
            },{
                text: '/include'
            },{
                text: '/info'
            },{
                text: '/lib'
            },{
                text: '/local'
            },{
                text: '/man'
            },{
                text: '/sbin'
            },{
                text: '/share'
            },{
                text: '/spool'
            },{
                text: '/src'
       	 }]

2. Define sunburst configuration:

{
    xtype: 'd3-sunburst',
    padding: 20,
    store: store
}
>/pre>

3. Add sunburst customization like tooltip or transition:
tooltip: {
	renderer: function (component, tooltip, node) {
    	var record = node.data,
            n = record.childNodes.length;
 
            tooltip.setHtml(n + ' folder' + (n === 1 ? '' : 's') + ' inside.');
    	
	}
},
transitions: {
	select: false
},
listeners: {
	selectionchange: function(sunburst, node) {
        sunburst.zoomInNode(node);
	}
},
expandEventName: false

Fiddle:

Pack

The 'd3-pack' component uses D3's Pack Layout to visualize hierarchical data as an enclosure diagram.

Pack

1. Get hierarchical data:

	text: '/usr',
            children:[{
                text: '/X11R6'
            },{
                text: '/bin'
            },{
                text: '/doc'
            },{
                text: '/etc'
            },{
                text: '/games'
            },{
                text: '/include'
            },{
                text: '/info'
            },{
                text: '/lib'
            },{
                text: '/local'
            },{
                text: '/man'
            },{
                text: '/sbin'
            },{
                text: '/share'
            },{
                text: '/spool'
            },{
                text: '/src'
            }]

2. Define pack configuration:

{
        xtype: 'd3-pack',
        store: store
}

3. Add pack customization like tooltip:

tooltip: {
	renderer: function (component, tooltip, node) {
    	var record = node.data,
            n = record.childNodes.length,
            html = '' + record.get('text') + '
'; html += n + ' folder' + (n === 1 ? '' : 's') + ' inside.'; tooltip.setHtml(html); } }

Fiddle:

Try Ext JS 7.2

The Ext JS free trial provides access to the Enterprise Edition (containing the framework, 140+ components and the premium tools and components - D3 Adapter, Pivot Grid, Calendar and much more!). Download 30-day free trial (npm or zip options).

Did You Know?

FusionCharts, a powerful charting library is now an integral part of the Idera family and offers 100+ interactive charts, data-driven maps, as well as visually appealing dashboard for web and mobile projects. Download a free trial today!

Recommended Articles

Guide to Estimating ROI When Switching From DIY Libraries to Full Software Development Platforms Like Ext JS

Teams started with Do It Yourself, or DIY, JavaScript tools like jQuery and Bootstrap. But those fall apart as projects scale. Scattered code, user interface…

Top Frameworks Developers Are Using for Custom Software Development in 2025

We’re seeing it more every year; teams aren’t settling for plug-and-play tools anymore. In healthcare, finance, logistics, and other data-heavy industries, there’s a clear shift.…

Meet Sencha AI Coding Companion: Your AI-Powered Assistant for Faster Ext JS Development

Building modern web applications should be exciting. But too often, developers find themselves buried in documentation, endlessly Googling framework quirks, or stuck solving the same…

Ext JS 7.9 & Rapid Ext JS V1.1 Have Arrived

The Sencha team is excited to announce the latest Ext JS version 7.9 and Rapid Ext JS 1.1 release – designed to accelerate development, enhance…

Top 10 JS Grid Customization Tips for a Better UI Experience

Grids are pretty much everywhere in web apps. Working with financial sheets, product details, or users? Then you’ve probably used a JavaScript grid. It makes…

Why Ext JS Framework is the Go-To Framework for Building Scalable and Data-Intensive Web Apps

Web apps are much more advanced now. They deal with large amounts of data and need to stay fast, even with many users. If you’re…

View More

Trusted by Top Developers: Learn how to enhance your development journey — for free

Get the latest newsletter keeping thousands of developers in the loop.

Loved by developers at