Marker Chart
Overview
Marker chart (also known as a point chart) is identical to a line chart without the lines. A marker chart shows only endpoints of segments that make each line up.
This article explains how to create a basic Marker chart as well as configure settings that are specific to the type. See the table below to get a brief overview of the Marker chart's characteristics:
API | |
---|---|
Class | anychart.core.cartesian.series.Marker |
DATA | |
Data Fields | x, value |
Multiple Series | YES |
OPTIONS | |
Stacked | N/A |
Vertical | Vertical Marker |
3D | N/A |
Error Bars | Marker Chart with Error Bars |
SUPPORTED CHART PLOTS | |
Polar | Polar Marker |
Radar | Radar Marker |
Scatter | Scatter Marker |
Stock | Stock Marker |
RELATED TYPES | |
Bubble | |
Dot (Point) Maps | |
SEE ALSO | |
Chartopedia: Marker Chart | |
General Settings |
Quick Start
To create a Marker chart, use the anychart.marker() chart constructor. If you pass the data to this chart constructor, it will create a Marker series. Note that this constructor creates a chart of a Scatter type. Find more about Scatter Charts in the Scatter Plot article.
To create a Marker series explicitly, call the marker() method.
In the following sample, we DO NOT create a Scatter Marker Chart, we create a basic categorized Marker chart:
// create a categorized chart
chart = anychart.cartesian();
// data
data = [
["2000", 1100],
["2001", 880],
["2002", 1100],
["2003", 1500],
["2004", 921],
["2005", 1000],
["2006", 1400]
];
// add a marker seris
chart.marker(data);
// set chart title
chart.title("Marker Chart");
// set axes titles
chart.xAxis().title("Years");
chart.yAxis().title("Sales");
// draw
chart.container("container");
chart.draw();
General Settings
In AnyChart there are many settings that are configured in the same way for all chart types, including the Marker chart (for example, legend and interactivity settings).
Read the overview of general settings: General Settings.
Special Settings
Size
It is possible to adjust the size of the markers to make them more noticeable or for any other reasons. Use size() method:
// set marker size
series.size(10);
The hoverSize() and selectSize() are used for adjusting the markers' size for the series in hovered and selected states.
// set marker size
series.hoverSize(15);
series.selectSize(15);
Appearance
Here is a full list of methods used to configure visual settings that are available for the Marker series:
- color(), fill(), hatchFill(), stroke() set the color, fill, hatch fill, and stroke
- hoverFill(), hoverHatchFill(), hoverStroke() methods configure the visual settings on hover
- selectFill(), selectHatchFill(), selectStroke() configure the visual settings on select
You can learn more from the Appearance Settings article.
In the sample below, there are two Marker series with some of the appearance settings configured:
// set colors
series1.fill("#00cc99", 0.5);
series1.stroke("#00cc99", 1, "10 5", "round");
series1.hoverFill("#00cc99", 0.2);
series1.hoverStroke("#00cc99", 2, "10 5", "round");
series1.selectFill("#00cc99", 0.8);
series1.selectStroke("#00cc99", 4, "10 5", "round");
series2.fill("none");
series2.hoverFill("none");
series2.selectFill("none");
series2.hatchFill("percent10");
series2.hoverHatchFill("percent30");
series2.selectHatchFill("percent50");
Note: settings adjusted in the dataset override those which are adjusted through the methods. Read more about setting the data and data formats in the Working with Data article.
Type
Markers can be of different shape. There are several marker types, which can be set through the type() method. The list of available marker types can be found on the Marker Types page.
// set marker types
series1.type("arrowDown");
series2.type("arrowUp");
Single Marker Adjusting
Sometimes it is necessary to emphasize an only item for some reasons. In this case, use your dataset to fix the parameters for detached markers instead of the whole series.
The following sample demonstrates adjusting some settings for a single item:
var data = anychart.data.set([
{x: "2000", value: 1100},
{x: "2001", value: 880},
{x: "2002", value: 1100},
{x: "2003", value: 1500, fill: "gold", stroke: "#663399", markerSize: 15, hoverMarkerSize: 15, selectMarkerSize: 20, type: "star5"},
{x: "2004", value: 921},
{x: "2005", value: 1000},
{x: "2006", value: 1400}
]);
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. 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.