Stick Chart
Overview
Stick Charts look like Column Charts with no width. Sticks are good at demonstrating some discrete data.
This article explains how to create a basic Stick chart as well as configure settings that are specific to the type. You can also see the table below to get a brief overview of Stick Chart's characteristics:
Modules | Core + Basic Cartesian / Base |
API | |
---|---|
Class | anychart.core.cartesian.series.Stick |
DATA | |
Data Fields | x, value |
Multiple Series | YES |
OPTIONS | |
Stacked | Stacked Stick, Percent Stacked Stick |
Vertical | Vertical Stick |
3D | N/A |
Error Bars | Stick Chart with Error Bars |
SUPPORTED CHART PLOTS | |
Polar | N/A |
Radar | N/A |
Scatter | N/A |
Stock | Stock Stick |
RELATED TYPES | |
Column | |
Line | |
HiLo | |
SEE ALSO | |
Chartopedia: Stick Chart | |
General Settings |
Modules
The Stick chart requires adding the Core and Basic Cartesian modules:
<script src="https://cdn.anychart.com/releases/8.13.0/js/anychart-core.min.js"></script>
<script src="https://cdn.anychart.com/releases/8.13.0/js/anychart-cartesian.min.js"></script>
Alternatively, you can use the Base module, which includes, among other things, the two modules mentioned above:
<script src="https://cdn.anychart.com/releases/8.13.0/js/anychart-base.min.js"></script>
Learn more: Modules.
Quick Start
Stick Chart is a variation of a Column, so when a Stick Chart is created it is necessary to create a Column Chart first and set the series of a Stick type.
To create a Stick chart, use the anychart.stick() chart constructor.
After you created a column chart use the stick() method.
// create data
var data = [
{x: "January", value: 10000},
{x: "February", value: 12000},
{x: "March", value: 18000},
{x: "April", value: 11000},
{x: "May", value: 9000}
];
// create a chart
chart = anychart.stick();
// create a stick series and set the data
var series = chart.stick(data);
General Settings
In AnyChart there are many settings that are configured in the same way for all chart types, including the Stick chart (for example, legend and interactivity settings).
Read the overview of general settings: General Settings.
Special Settings
Appearance
The appearance settings of a Stick chart can be configured in three states: normal, hover, and selected. Use the normal(), hovered(), and selected() methods.
Combine them with the stroke() method. Also, you can use some other methods from anychart.core.StateSettings.
In the sample below, there are two Stick series with appearance settings configured:
// create the first series
var series1 = chart.stick(seriesData_1);
// configure the visual settings of the first series
series1.normal().stroke("#00cc99", 1, "10 5", "round");
series1.hoverStroke("#00cc99", 2, "10 5", "round");
series1.selectStroke("#00cc99", 4, "10 5", "round");
// create the second series
var series2 = chart.stick(seriesData_2);
// configure the visual settings of the second series
series2.normal().stroke("#0066cc");
series2.hoverStroke("#0066cc", 2);
series2.selectStroke("#0066cc", 4);
Individual Points
If you use object notation to set the data, you can change the appearance (and some other settings) of individual points by adding special fields to your data:
// create data
var data = [
{x: "January", value: 10000},
{x: "February", value: 12000},
{x: "March", value: 18000,
normal: {stroke: "3 #5cd65c"},
hovered: {stroke: "4 #5cd65c"},
selected: {stroke: "4 #5cd65c"}
},
{x: "April", value: 11000},
{x: "May", value: 9000}
];
// create a chart
chart = anychart.column();
// create a stick series and set the data
var series = chart.stick(data);
Point Size
This chart type allows you to set the size of its points. Read more in the Point Size article.
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.
Tooltips
A Tooltip is a text box displayed when a point on a chart is hovered over. 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.
Stacked Stick
Stacked and percent stacked charts are multiple-series charts where related values are placed atop one another, which allows comparing the the contribution of a value to a total, either in absolute or percentage terms.
In AnyChart, you can enable a special mode of the scale to make series stack together: see Stacked Charts.
To learn about the stacked versions of the Stick chart and its modifications, see:
Vertical Stick
Most types of series in AnyChart can be drawn both in horizontal and vertical orientation: Vertical Charts (Overview).
Here is information about creating Vertical Stick series: