Sheerpower Logo
B.7  Transform Data into Stunning Visuals

SheerPower Charts: Transform Data into Stunning Visuals

SheerPower includes a powerful charting facility to visualize data in various formats such as bar charts, line charts, scatter plots, Pie, and doughnut charts. This tutorial will guide you through creating charts using SheerPower's simple and intuitive charting statements.

Main Features of SheerPower Charts

  • Multiple Chart Types: Choose from bar, line, pie, donut, and scatter charts.
  • Dynamic Configuration: Customize colors, labels, axes, and point radii.
  • Simple Syntax: Intuitive chart creation with minimal effort.
  • Responsive Output: Charts are optimized for display across devices and include built-in interactive tooltips for all data points.
  • Stacked bars: Use the stacked option to produce stacked bars.
  • Data Mining: Any data point can be associated with a URL using the LINK option. The link becomes active when the user clicks on the corresponding data point.

Basic Structure

Creating charts involves the following simple steps:

  • START CHART: Define the chart type, title, and output file.
  • ADD CHART: Add data points with x-axis and y-axis values, labels, and styles.
  • SET CHART: dynamicaly adjust colors, point radius, and others on a per-data point basis.
  • END CHART: Finalize and render the chart.

Bar Chart with two Datasets

(Show/Hide Code)

Enhanced Bar Chart Example

In this example, we demonstrate how to create a colorful bar chart with SheerPower. The chart showcases monthly revenue data with custom styles for the canvas, title, axes, and tick labels.

Line Chart with two Datasets

Pie Chart

Donut Chart

Scatter Plot Chart


Objective

Create a line chart from a CSV file, using clusters .

Here is a sample program that uses two datasets to compare monthly daily average temperatures between Chicago and San Diego.
Here is the data for the program:
Month,Chicago,San Diego January,26.4,57.4 February,30.6,58.1 March,39.4,59.4 April,50,61.5 May,60.4,63.6 June,70.1,67.5 July,75.9,71 August,74.6,72.4 September,67.8,71.6 October,55.7,68.6 November,43,62.8 December,30.9,57.8

Inserting Charts into Web Pages
This is how charts are typically inserted into webpages:
<center>
<iframe src="/html/temperature_bar_chart.html" width="700" height="450"></iframe>
</center>

Below are two interactive graphs. Hover over the plotted data for tooltips. The green data is clickable!


Change the chart type from type "line" to type "bar" and we get this chart:

The most common mistake when coding charts is incorrect use of commas between parameter pairs. This often includes either using too many or too few commas, with one of the most frequent errors being the omission of a trailing comma at the end of a line.

Advanced Features

  • Dynamic Point Radii: Adjust point_radius for scatter or line charts.
    set chart: point_radius 10
  • Custom Colors: Set background_Color and border_Color for individual points.
    set chart: background_Color "gold", border_Color "black", tooltip "click for more', link "https://www.wikipedia.org/"
  • Tooltips and Interactivity: Tooltips are automatically provided. They interactively display labels and values on hover. You can add your own tooltips as well.

Working with Large Data Sets in SheerPower

When dealing with large data sets, generating charts directly from the entire data set might be impractical due to size or performance constraints. Instead, sampling or summarizing the data before creating a chart is often a more efficient approach.

SheerPower excels in these tasks with its ability to process large data sets rapidly. Incorporating sampling and summarization directly into your chart generation code can significantly enhance performance and usability.

START CHART Parameter Reference

The START CHART statement initializes the chart and sets global properties. The following table lists the supported parameters and their purposes:

start chart: type "bar", title "Monthly Revenue", output "revenue_chart.html", size "800x600", x_axis_label "Month", y_axis_label "Revenue"

ADD CHART and SET CHART Parameter Reference

The ADD CHART statement defines a new data point or dataset. The SET CHART statement modifies properties of an existing dataset or data point.

The following table lists the supported parameters and their purposes:

Example 1: Adding New Data Points with Custom Properties

add chart: x_axis = "January", y_axis = "1200", label = "Revenue", background_Color = "blue", border_Color = "darkblue", point_radius = 5

Example 2: Updating Data point Properties with SET CHART

set chart: background_Color = "gold", border_Color = "darkgoldenrod", point_radius = 8

Summary

SheerPower charts are a simple yet powerful way to visualize data. The start chart, add chart, set chart, and end chart statements provide a clear and intuitive workflow for quickly creating visually compelling charts. Supported types of charts include:

  • Bar Chart: Displays data points expressed by vertical bars (type 'bar'). The bars can also be stacked using the START CHART stacked true option.
  • Line Chart: Displays data points connected by lines (type 'line').
  • Pie Chart: Circular chart divided into slices to show proportions (type 'pie').
  • Doughnut Chart: Similar to a pie chart but with a hole in the center (type 'doughnut').
  • Scatter Chart: Displays data points on an x-y Cartesian plane without connecting lines (type 'scatter'). You can also make Bubble Charts by varying the pointer_radius using ADD CHART or SET CHART.
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.