DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Data
  4. Analyze Your Tabular Data and Visualize it With Charts

Analyze Your Tabular Data and Visualize it With Charts

If you can't visualize your data, it'll be that much harder for your findings to make an impact. Read on to learn how to use JavaScript to make great data viz.

Veronika Rovnik user avatar by
Veronika Rovnik
·
Sep. 03, 18 · Tutorial
Like (11)
Save
Tweet
Share
7.16K Views

Join the DZone community and get the full member experience.

Join For Free

Many business analysts face the problem of presenting the data from the spreadsheets or business reports. If you want to learn about a more sophisticated way of doing data analysis, you may find to link your report to data with charts. I'd like to show you a solution I’ve reached.

After researching the available tools which don’t need a complicated installation process, I’ve chosen the following ones:

  • WebDataRocks:  A web reporting tool for data aggregation, sorting, filtering, and further displaying it in the pivot table. It’s free, has a user-friendly interface and can be embedded into an application with any front-end (e.g., Angular 2+, React.js) and backend technologies.

  • Highcharts: A dynamic charting library which supports a wide range of charts types: area, areaspline, bar, pie, bubble, column, etc. It allows for the custom preprocessing of data and element customization. It is free for non-commercial use. For commercial needs, it offers a free trial to test its functionality.

To my mind, both tools complement each other well in achieving smart data visualization goals. In this tutorial, I will explain how to create a dashboard with a pivot table and colorful charts. Moreover, the chart will be updated as soon as the data in the table is updated, sorted, or filtered. In practice, it is easier than it sounds. The process will be illustrated with an example on CodePen and enriched with explanations. You can scroll down to see the full code if you feel unsure about some steps.

Ready to make your data presentation more interesting and interactive? Let’s start.

Step 1: Data Preparation

Before the start, I’ve defined a function which returns an array of my JSON data:

function getJSONData() {
    return [{
            "Country": "Australia",
            "Category": "Wood",
            "Price": 445,
            "Revenue": 464
        }, {
            "Country": "Australia",
            "Category": "Bikes",
            "Price": 125,
            "Revenue": 440
        },
        //
    ]
}

Step 2: Embedding the Pivot Table

I’ve read a Quickstart, included the scripts and styles of WebDataRocks in my webpage:

<link href="https://cdn.webdatarocks.com/latest/webdatarocks.min.css" rel="stylesheet"/>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<div id="wdr-component"></div>

Step 3: Aggregation

Next, I’ve moved on to defining the slice of the data which will be shown in the table and passed to the chart. As I’m going to conduct an analysis on which country from the dataset is the most profitable. I’ve put Country into rows, Price and Revenue into Measures. Also, to discover which category of merchandise brings the lion’s share of the revenue, I’ve added Category to columns. Now my basic pivot’s configuration looks like the following:

var pivot = new WebDataRocks({
    container: "#wdr-component",
    toolbar: true,
    report: {
        "dataSource": {
            "dataSourceType": "json",
            "data": getJSONData()
        },
        slice: {
            rows: [{
                uniqueName: "Country"
            }, {
                uniqueName: "[Measures]"
            }],
            columns: [{
                uniqueName: "Category"
            }],
            measures: [{
                uniqueName: "Price"
            }, {
                uniqueName: "Revenue"
            }]
        }
    }
});

Image title

Step 4: Connecting to Highcharts

After reading an Installation guide, I’ve included a Highcharts’s script into my webpage, a WebDataRock’s connector for Highcharts and the container for the chart:

<script src="https://code.highcharts.com/4.2.2/highcharts.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.highcharts.js"></script>
<div id="highchartsContainer"></div>

Step 5: Exporting the Data from the Pivot Table to the Chart

Now it’s time to define a function which will be responsible for creating and drawing the chart:

function createChart() {
    pivot.highcharts.getData({
        type: "spline"
    }, function(data) {
        $('#highchartsContainer').highcharts(data);
    }, function(data) {
        $('#highchartsContainer').highcharts(data);
    });
}

Step 6: Enjoy Your Data Presentation

Let’s see what data visualization results were achieved by using these 5 steps:

Image title

Try to experiment with the data: change the hierarchy in rows, apply different measures or filter the data and see how the view of the chart is changed at once.

I hope you’ve found this tutorial useful, too, and discovered a new effective way of customizing your reports. The full code is available on CodePen.

It would be my pleasure to receive feedback about your experience combining these tools. Please leave your questions and suggestions in the comments and stay tuned for updates!

Data visualization Chart Database Analyze (imaging software) IT

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Keep Your Application Secrets Secret
  • Multi-Tenant Architecture for a SaaS Application on AWS
  • Test Execution Tutorial: A Comprehensive Guide With Examples and Best Practices
  • DeveloperWeek 2023: The Enterprise Community Sharing Security Best Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: