Your first linear gauge
- Overview
- Step 1. Basic Gauge - Choosing Layout
- Step 2. Scale Settings and Title
- Step 3. Labels and Tickmarks
- Step 4. Color Ranges
- Step 5. Adding Markers
- Step 6. Pointer
- Step 7. Tuning frame and Margins
- Final. Monthly Sales Gauge is Ready
Overview
In this tutorial we will go through the creation of the basic linear gauge step by step, trying to cover all major elements and pointing to the articles for the further tuning a gauge.
So, a Linear Gauge is a slider, with a single or multiple pointers to show your data value, gauge has some scale, usually colored for easy value quality distinction.
We will start from the scratch adding or configuring gauge elements on the each step, as a result we will create a typical ACME Corp. Monthly Sales Level gauge.
Note: in this sample AnyChart.swf is used, but you can optimize the page with selected chart type if you use custom type dependent swf. These swfs are described in SWFs Guide.
Gauge Sample:
Step 1. Basic Gauge - Choosing Layout
First of all we need to choose a gauge type, in this sample it should be horizontal linear gauge, so we put the following XML settings:
As you can clearly see from this XML Snippet we tell AnyChart to create one linear gauge with horizontal orientation, as a result we get the following output:

As you can see, by default gauge has no pointers and some default scale with labels and tickmarks, when trying to recreate this sample please note that you should set appropriate size for AnyChart object in you page (height="150" width="500" in our sample). AnyChart Gauges can be resized, but if you want to create the horizontal linear gauge - it is recommended to start with width that is greater than height.
Step 2. Scale Settings and Title
Now we will define the scale of the gauge, let's say that ACME Corp. monthly sales level is measured in thousands of dollars from 0 to 1000 th.
Let's put this into XML:
Note: <axis size="50"> means that we want gauge axis to cover 50% percents of a gauge height - to understand this better you need to study Positioning, Resizing and Axis Overview Tutorials.
Now we will see the following result:

Step 3. Labels and Tickmarks
When the scale is ready we can set how labels and tickmarks, we will remove decimal digits from labels and minor tickmarks. Only axis node is shown for better comprehension:
Now the scale looks this way:

Step 4. Color Ranges
An essential part of linear gauges are color ranges that are used to distinct the quality of value shown, in our example we will create three color ranges "Bad", "Good" and "Excellent" sales levels. The syntax should be as follows:
Here we are - our gauge is colored:

Step 5. Adding Markers
Also, it may be useful to point our some special point, for example, planned sales level, we can so that with the custom axis labels, that can have a custom tickmark.
Now we can clearly see planned level on a gauge.

Step 6. Pointer
One of the last, but one of the main parts of a gauge is a pointer - there are several ways to display it, but we will choose the most typical for this type of the gauges (all previously set nodes are left apart in the snippet):
Now the current sales level is shown, as you can see from the syntax you can place several pointers on one gauge, they can be of a different shape and placed differently (this fact, by the way, allows to create the Bullet Graphs with AnyChart easily):

Step 7. Tuning frame and Margins
The final step in gauge creation is the definition of a frame and setting up margins. Frame is a complex graphical element that allows to display really nice-looking gauge. We will remove a general chart background and border, remove margins and configure frame in a desirable way.
And here is an output we get:

Final. Monthly Sales Gauge is Ready
Now you know almost all basic settings and configurations of the gauge, you can go on studying a lot of other parameters that can be changed to create a gauge that will display the data of your choice in a right way.
If you haven't studied any other articles in documentation yet we recommend you to start with the following:
