Quadrant Chart

Overview

Technically, a quadrant chart is a scatter chart divided into four quarters (quadrants) to make the visualization more readable. This chart type is used when data can be categorized into quadrants – for example, in SWOT-analysis.

In AnyChart, Quadrant charts are combined with Marker, Bubble, and Line series.

This article explains how to create a basic Quadrant chart as well as configure settings that are specific to the type.

Quick Start

To create a Quadrant chart, use the anychart.quadrant() chart constructor.

This constructor creates a Scatter chart with some predefined settings:

  • The chart is framed with two X and Y axes.
  • Ticks and labels on the axes are disabled.
  • There are no grids.
  • The minimum and maximum values of the scales are 0 and 100.
  • The right-top and left-bottom quarters are colored.

Like the scatter constructor, it processes data points as-is: sets of arguments from different series don't influence each other, points are shown in the exact order they are set, and lines can be vertical and cross themselves. While the Cartesian constructor distributes points along the X-axis at equal intervals (categories), the scatter and quadrant constructors distribute points according to their values.

If you just pass the data to the chart constructor, it creates a Marker series. But you can also create a Marker, Bubble, or Line series explicitly by using one these methods:

The following sample demonstrates how a basic Quadrant chart is created:

// create data
var data = [
  {x: 4, value: 42},
  {x: 13, value: 59},
  {x: 25, value: 68},
  {x: 25, value: 63},
  {x: 44, value: 54},
  {x: 55, value: 58},
  {x: 56, value: 46},
  {x: 60, value: 54},
  {x: 72, value: 73}
];

// create a chart
chart = anychart.quadrant(data);

// set the container id
chart.container("container");

// initiate drawing the chart
chart.draw();

Playground

General Settings

In AnyChart there are many settings that are configured in the same way for all chart types, including the Quadrant chart (for example, legend and interactivity settings).

Read the overview of general settings: General Settings.

Special Settings

Appearance

Each of the supported series types has its own visual settings – see the following articles:

Also, you can learn more from the Appearance Settings section.

In this sample there are three series (Marker, Line, and Bubble) with some of the appearance settings configured:

// create the first series (marker) and set the data
var series1 = chart.marker(data_1);

// configure the visual settings of the first series
series1.fill("black", 0.3);
series1.hoverFill("black", 0.3);
series1.selectFill("black", 0.5);
series1.stroke("black", 1);
series1.hoverStroke("black", 2);
series1.selectStroke("black", 4);

// create the second series (line) and set the data
var series2 = chart.line(data_2);

// configure the visual settings of the second series
series2.stroke("#00cc99", 3, "10 5", "round");

// create the third series (bubble) and set the data
var series3 = chart.bubble(data_3);

// configure the visual settings of the third series
series3.fill("#0066cc", 0.3);
series3.hoverFill("#0066cc", 0.3);
series3.selectFill("#0066cc", 0.5);
series3.stroke("#0066cc");
series3.hoverStroke("#0066cc", 2);
series3.selectStroke("#0066cc", 4);

Playground

Quarters

Each Quadrant chart has four quarters (quadrants), which can be configured separately. Use these methods to access and configure them:

The following methods configure visual settings of quartes:

The sample below shows how to set the fill and corners:

// configure quarters
chart.quarters(
        {
            rightTop: {
                fill: "#ccfff2",
                corners: 30,
                cornerType: "cut"
            },
            rightBottom: {
                fill: "#e6f9ff",
                corners: 30,
                cornerType: "cut"
        }
);

Playground

You can also configure titles, margins, paddings, and labels of quarters (see the Labels section of this article to find more information about configuring lables):

The following sample shows how to set titles:

// configure quarters
chart.quarters(
        {
            rightTop: {
                title: {
                    text: "Right Top",
                    fontSize: "24",
                    fontWeight: "bold",
                    fontColor: "#fa8072"
                }
            },
            rightBottom: {
                title: {
                    text: "Right Bottom",
                    fontSize: "24",
                    fontWeight: "bold",
                    fontColor: "#72fa80"
                }
            },
        }
);

Playground

Crossing

To configure the intersecting lines ("crossing") in the center of a Quadrant chart, use the stroke() method:

// configure the crossing
chart.crossing().stroke("gray", 3, "7 3", "round");

Playground

Scales

In Quadrant charts data do not affect scales: the data falling outside scales just are not displayed.

By default, the minimum and maximum values of the X and Y scales are 0 and 100, but you can change these settings (read more in the Scales article):

// configure scales
chart.yScale().minimum(-100);
chart.yScale().maximum(100);
chart.xScale().minimum(-100);
chart.xScale().maximum(100);

Please note that quarters always divide scales into two parts, no matter what the minimum and maximum values are. So, the lines in the center of the chart ("crossing") intersect in the origin only in one case: if the minimum and maximum values are of the same absolute value, like in the sample code above. You can go to the Axes section to see how it looks like.

Axes

The Quadrant chart is framed by two X and Y axes, which can be referred to by indexes (0 and 1). By default, ticks, labels, and titles are disabled, but you can enable them – read more in the Axes and Grids article:

// configure axes
chart.xAxis(0, {ticks: true, labels: true});
chart.xAxis(1, {ticks: true, labels: true});
chart.yAxis(0, {ticks: true, labels: true});
chart.yAxis(1, {ticks: true, labels: true});

Playground

Labels

Labels are text or image elements that can be placed anywhere on any chart (you can enable them on a whole series or in a single point). For text labels, font settings and text formatters are available.

Labels of series are configured according to the rules of the series type – for example, see the Marker Chart article. You can also configure labels of quarters by using the label() method. Please note that a quarter can have more than one label.

The sample below shows how to create quarter labels:

// create the first label on the left-bottom quarter
var labelLBottom1 = chart.quarters().leftBottom().label(0);
labelLBottom1.text("3");
labelLBottom1.fontColor("gray");
labelLBottom1.fontWeight("bold");
labelLBottom1.position("rightTop");
labelLBottom1.fontSize(16);
labelLBottom1.offsetX(-20);
labelLBottom1.offsetY(20);

// create the second label on the left-bottom quarter
var labelLBottom2 = chart.quarters().leftBottom().label(1);
labelLBottom2.useHtml(true);
labelLBottom2.text("Important / Not Important →");
labelLBottom2.position("leftBottom");
labelLBottom2.offsetX(-20);
labelLBottom2.offsetY(-100);
labelLBottom2.rotation(-90);

Playground

Tooltips

A Tooltip is a text box displayed when a point on a chart is hovered. There is a number of visual and other settings available: for example, you can edit the text by using font settings and text formatters, change the style of background, adjust the position of a tooltip, and so on.

You are looking at an outdated v7 version of this document. Switch to the v8 version to see the up to date information.