Scales are included into the following chart types:
At the same time, radar chart has a specific scale type.
Scales consist of Y and X axes that are chart properties the values of which are objects containing several properties. Note that scales won't appear during chart initialization by default, if you don't include these properties into the chart constructor:
webix.ui({
view:"chart",
...
xAxis:{
property:"value"},
yAxis:{
property:"value"}
})
If needed, any axis can be omitted.
Let's suppose that we have a dataset presented below and we want to present sales progress during several years. Each data item contains sales amount and the year.
JSON data
[
{ id:1, sales:20, year:"02"},{ id:2, sales:55, year:"03"},
{ id:3, sales:40, year:"04"},{ id:4, sales:78, year:"05"},
{ id:5, sales:61, year:"06"},{ id:6, sales:35, year:"07"},
{ id:7, sales:80, year:"08"},{ id:8, sales:50, year:"09"},
{ id:9, sales:65, year:"10"},{ id:10, sales:59, year:"11"}
]
If you set an empty yAxis property object (yAxis:{}), the dataset will be analyzed and the scale will be formed automatically. Here:
Minimal compulsory API for the x-Axis includes
Y-axis object is constructed with the following properties:
If you don't want to label each unit, you can set a function template to label only units multiplied by the specified number (here it's 20):
template:function(obj){return (obj%20?"":obj)}
There exists a possibility to create a fully custom axis for working with dates.
For line, scatter and area charts you can set the offset property which defines whether the first item of the scale will be drawn with the offset equal to the half of the scale's step (relative to the origin of the chart).
The default value for line and scatter charts is true. The default value for area charts is false.
webix.ui({
view:"chart",
type:"line",
...
xAxis:{
property:"value"},
yAxis:{
property:"value"},
offset:false
})
Related sample: Line Chart: Axes
Webix charts are equipped with two types of scale:
webix.ui({
view:"chart",
type:"bar",
scale: "logarithmic",
...
});
Related sample: Chart: Logarithmic Scale
Titles are included into axes' objects:
webix.ui({
view:"chart",
..config..,
xAxis:{ ..
title: "Year"},
yAxis:{..
title:"Sales per Year"}
})
In case of horizontal bar charts (type barH, stackedBarH) X and Y axes exchange their properties.