Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 21, 2021 07:26 pm GMT

Visualizing Sales Data with Arctype Dashboards

Introduction

What is Arctype?

Arctype is a high-performance SQL client that lets you manage your database with a simple user interface. It also enables you to build visualizations straight from queries, modify databases in the same way that you would spreadsheets, and share frequently used SQL queries with your team.
arctype.com homepage

What are Arctype Dashboards?

Arctype dashboards allow you to generate charts and tables to examine your data. You can also use them to create tools that modify and visualize data from your database and automate technical and tedious activities.

Prerequisites

To follow and fully understand this tutorial, you need to have the following:

Preparing Our Database

Acquiring Sample Sales Data

We will need to get sales data to visualize. In this tutorial, we will use publicly available data, which you can download here.
The dataset is only 1MB and includes the name, platform, year of release, genre, publisher, and global sales of about 16,000 video games from Metacritic.
meta critic dataset spreadsheet csv

Importing Our Dataset into Arctype

Next, we need to create a table in Arctype and import the dataset. To do this, use the Import Table button from the Arctype client.

arctype import table from csv

After doing that, select the CSV file to import. Arctype will show you a preview of the data you are about to import. If it is correct, press the Accept button located at the bottom right of the pop-up.
csv data import preview

Then, we need to confirm the automatically generated schema of our table from the imported CSV:
csv import schema settings

We will be renaming the new table to sales. We also need to change the datatype of the year_of_release column to int and the global_sales column to double.

After doing that, press the Import CSV button located at the bottom right of the pop-up.

arctype table view mysql imported data

Creating an Arctype Dashboard

Visualizing Total Sales with Arctype

Now, lets begin visualizing our database using Arctype. We will start by displaying a count of all sales made. Arctype dashboards provide a handy component called scorecard Which shows a value on a card.

To do this, we need to write an SQL query that will fetch the count of the records. Click on the Queries tab by the Arctype sidebar (left side of the screen), then click on the Create Query button.

arctype create query from table view MySQL

Paste and save the following query in the editor that comes up:

SELECT    COUNT(*) AS sales_count FROM     sales;

You should get a result that looks like the screenshot below when you run the query in Arctype:
arctype query view with results pane

Next, click on the Dashboards tab by the Arctype sidebar (left side of the screen), then click on the Create Dashboard button.

arctype create dashboard from query view

Then, click the Add button at the header of the Dashboards section and select Chart.
arctype dashboard add chart

Now, click on the Select chart data button and select the sales count query we created earlier.
Arctype dashboard chart select chart data

Navigate to the right sidebar. Change the title of the dashboard component, select Scorecard as the chart type and drag the sales_count column to be displayed.
dashboard

Visualizing Tables with Arctype

Lets create a table component with Arctype to display the names of the games with the most sales.

Create a new query called top sales and save the following code in it:

SELECT     name,    global_sales AS sales FROM     sales ORDER BY     global_sales DESC LIMIT 10;

arctype sales query view with results

Then, click the Add button at the header of the Dashboards section and select Table.
dashboard

Once you have done that, click on the Select chart data button and select the top sales query we created earlier.
dashboard

Creating Pie Charts with Arctype

Lets create chart components with Arctype to display the game platforms and genre grouped into pie charts.

Create a new query called platforms and save the following code in it:

SELECT     platform,     COUNT(*) AS platform_count FROM     sales GROUP BY     platform;

Next, create another new query called genres and save the following code in it:

SELECT     genre,     COUNT(*) AS genre_count FROM     sales WHERE     genre IS NOT NULL GROUP BY     genre;

Then, click the Add button at the header of the Dashboards section and select Chart. Select Pie chart as the chart type, and drag the platform column to the category box and the platform_count column to the values box.
arctype dashboard pie chart game platforms

Repeat the process to generate a pie chart for the genres query:
arctype dashboard pie chart game genre breakdown

Creating Bar Charts with Arctype

Lets create chart components with Arctype to display the number of games released each year and game publishers on a bar chart.

Create a new query called year_of_release and save the following code in it:

SELECT     year_of_release,     COUNT(*) as release_count FROM     sales WHERE     year_of_release IS NOT NULL GROUP BY     year_of_release ORDER BY     year_of_release;

Next, create another new query called publisher and save the following code in it:

SELECT     publisher,     COUNT(*) AS publisher_count FROM     sales GROUP BY     publisher LIMIT 15;

Then, click the Add button at the header of the Dashboards section and select Chart.

After doing that, click on the Select chart data button and select the year_of_release query we created earlier. Also, change the title of the dashboard component, select Bar Chart as the chart type, and drag the year_of_release column to the x-axis box and the release_count column to the y-axis box.
arctype dashboard bar chart game releases by year

Repeat the process to generate a horizontal bar chart for the publisher query:

arctype dashboard horizontal bar chart

Creating Doughnut Charts with Arctype

Lets create a doughnut chart with Arctype for our publisher query. Click the Add button at the header of the Dashboards section and select Chart.

Change the title of the dashboard component, select Doughnut Chart as the chart type, and drag the publisher column to the category box and the publisher_count column to the values box.
arctype dashboards donut chart

Creating Line Charts with Arctype

Lets create a chart component with Arctype to display the annual number of game sales on a line chart.

Create a new query called annual_game_sales and save the following code in it:

SELECT     year_of_release,     SUM(global_sales) AS sales FROM     sales WHERE     year_of_release IS NOT NULL GROUP BY     year_of_release ORDER BY     year_of_release;

Just like all other chart types, select Line Chart as the chart type, and drag the year_of_release column to the x-axis box and the sales column to the y-axis box.

arctype dashboard line chart

Creating Area Charts with Arctype

Lets create an area chart with Arctype for our annual_game_sales query. Click the Add button at the header of the Dashboards section and select Chart.

Select Area Chart as the chart type, and drag the year_of_release column to the x-axis box and the sales column to the y-axis box.

arctype dashboards line chart

Introducing Query Variables for Dynamic Results

We have been creating visualizations based on specific queries with set parameters. What if we wanted to give Arctype input and have it create visualizations based on our information? We can use query variables to assist us in addressing this problem.

Query variables allow you to connect variables to your queries and provide various values for them during execution. They function similarly to prepared statements, which enable you to construct a query's structure and pass values to the parameters inside it.

Using Query Variables in Arctype

We will create a query to return the number of game sales in a year using query variables. Create a new SQL query named yearly_sales and save the following code in it:

SELECT     SUM(global_sales) AS year_sales FROM     sales WHERE     year_of_release = {{year}};

When this query executes in Arctype, you will notice that it lets you provide value for the year variable. This is because query variables prepare a query structure, then provide the functionality to pass different values to the variables to get desired results.

arctype query view query variables

Using Query Variables in Dashboards

We will create a scorecard to display the result of the yearly_sales query with a query variable. To do this:

  • Create a dashboard component,
  • Select the yearly_sales query as the data source,
  • Change the chart type to a scorecard,
  • Drag the year_sales column to the display text box.

arctype dashboard scorecard with query variable

You will notice that the year variable also appears by the right sidebar. Changing this value will instantaneously update the result of the scorecard.

actype dashboard query variables before change

arctype dashboard query variables after change

Conclusion

In this article, we learned about Arctype and saw how to visualize sales data using its built-in dashboards. We also explored query variables and used them to generate dynamic visualization results.

You can learn more about Arctype from the official documentation. If you have any questions, don't hesitate to contact me on Twitter: @LordGhostX.


Original Link: https://dev.to/arctype/visualizing-sales-data-with-arctype-dashboards-b3a

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To