dataSource: [{ arg: "", cat1: 8, cat2: 5 }, { arg: " ", cat1: 7, cat2: 3 }, { arg: "", cat1: 7, cat2: 6 }, { arg: "", cat1: 7, cat2: 8 }, { arg: "", cat1: 6, cat2: 8 }, { arg: "", cat1: 8, cat2: 5 }]
The cat1 field corresponds to information about the Maine Coon breed, and cat2 corresponds to the British Shorthair. We describe this in two series: series: [{ name: "-", valueField: "cat1" }, { name: " ", valueField: "cat2" }]
The types of both series are areas with a stroke, so we will describe these properties for all series: commonSeriesSettings: { type: "area", border: { visible: true } }
Since the evaluation in our graph is made on a ten-point scale, we add all these points to the scale of values: valueAxis: { categories: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }
Well, with the data sorted out, move on to the rest of the elements. Enable the tooltip: tooltip: { enabled: true }
We describe the two-line header: title: " \n "
Place the legend under the heading, and align the text to the right of the series markers: legend: { horizontalAlignment: "center", itemTextPosition: "right" }
And the final touch, since we want to make a web graph, we describe the property: useSpiderWeb: true
options = { title: " \n ", useSpiderWeb: true, dataSource: [{ arg: "", cat1: 8, cat2: 5 }, { arg: " ", cat1: 7, cat2: 3 }, { arg: "", cat1: 7, cat2: 6 }, { arg: "", cat1: 7, cat2: 8 }, { arg: "", cat1: 6, cat2: 8 }, { arg: "", cat1: 8, cat2: 5 }], commonSeriesSettings: { type: "area", border: { visible: true } }, series: [{ name: "-", valueField: "cat1" }, { name: " ", valueField: "cat2" }], valueAxis: { categories: [1,2,3,4,5,6,7,8,9,10] }, legend: { horizontalAlignment: "center", itemTextPosition: "right" }, tooltip: { enabled: true } }
dataSource: [{ arg: 1, val: 12000000 },{ arg: 2, val: 14000000 },{ arg: 3, val: 13000000 },{ arg: 4, val: 18000000 },{ arg: 5, val: 21000000 },{ arg: 6, val: 16000000 }]
The series is one here and has a line type series: { type: "line" }
Let's write a two-line header: title: " \n "
And turn off the legend, for one series, it is clearly superfluous here: legend: { visible: false }
We will understand the axles. Let's start with the value axis. Since our data contains large numbers of sales, millions, to be more precise, we will present our signatures on the axes in this format: valueAxis: { label: { format: "millions" } }
Now the axis of the arguments. First of all, we will set the period equal to 3 months, that is, one quarter. Next, we set the interval for the arguments, because we only need to show signatures for months. And so that the signatures have a postscript “month”, let them be casted. argumentAxis: { period: 3, tickInterval: 1, label: { customizeText: function(label) { return label.valueText + " "; } } }
options = { title: " \n ", dataSource: [{ arg: 1, val: 12000000 },{ arg: 2, val: 14000000 },{ arg: 3, val: 13000000 },{ arg: 4, val: 18000000 },{ arg: 5, val: 21000000 },{ arg: 6, val: 16000000 }], series: { type: "line" }, argumentAxis: { period: 3, tickInterval: 1, label: { customizeText: function(label) { return label.valueText + " "; } } }, valueAxis: { label: { format: "millions" } }, legend: { visible: false } }
dataSource: [{ arg: "", day: 8, night: 6 },{ arg: "", day: 3, night: 2 },{ arg: "", day: 1, night: 1 },{ arg: "", day: 0, night: 2 },{ arg: "", day: 4, night: 3 },{ arg: "", day: 2, night: 1 },{ arg: "", day: 4, night: 4 },{ arg: "", day: 6, night: 4 }]
Here we have two series, one of which corresponds to the day field - data about the wind during the day, and the other to the night field - data about the wind at night. Also each series will have the corresponding color: series: [{ name: " ", valueField: "day", color: "#FFD700" }, { name: " ", valueField: "night", color: "#009ACD" }]
Also, each of these series has a line type, and points of small size: commonSeriesSettings: { type: "line", point: { size: 6 } }
Let's write a two-line header: title: " \n 2014"
Since we want the first argument, north, to be exactly on top, we indicate this in the axis of the arguments: argumentAxis: { firstPointOnStartAngle: true }
Now we describe the axis of values. First of all, we point out that not the main, minor, marks on the axis have an interval of one day, so they look much clearer. Let's add a “d” to the signatures on the axis: minorTickInterval: 1, label: { customizeText: function(label) { return label.valueText + " "; } }
It remains to specify the information about the calm on days and nights. To do this, we will use the usual broken lines, which will give their value, the corresponding color and the signature “Calm”: constantLines: [{ value: 5, color: "#FFD700", dashStyle: "dash", label: { text: "", font: { color: "#FFD700" } } }, { value: 7, color: "#009ACD", dashStyle: "dash", label: { text: "", font: { color: "#009ACD" } } }]
options = { title: " \n 2014", dataSource: [{ arg: "", day: 8, night: 6 },{ arg: "", day: 3, night: 2 },{ arg: "", day: 1, night: 1 },{ arg: "", day: 0, night: 2 },{ arg: "", day: 4, night: 3 },{ arg: "", day: 2, night: 1 },{ arg: "", day: 4, night: 4 },{ arg: "", day: 6, night: 4 }], commonSeriesSettings: { type: "line", point: { size: 6 } }, series: [{ name: " ", valueField: "day", color: "#FFD700" }, { name: " ", valueField: "night", color: "#009ACD" }], argumentAxis: { firstPointOnStartAngle: true }, valueAxis: { minorTickInterval: 1, label: { customizeText: function(label) { return label.valueText + " "; } }, constantLines: [{ value: 5, color: "#FFD700", dashStyle: "dash", label: { text: "", font: { color: "#FFD700" } } }, { value: 7, color: "#009ACD", dashStyle: "dash", label: { text: "", font: { color: "#009ACD" } } }] }
dataSource:[{ arg:"", usa_male: 134782000, usa_female: 140786000 },{ arg: "", brazil_male: 85127000, brazil_female: 87730000 },{ arg: "", rus_male: 68278000, rus_female: 64750000 },{ arg: "", japan_male: 52387000, japan_female: 64586000 },{ arg: "", ger_male: 40450000, ger_female: 42344000 },{ arg: "", gb_male: 23486000, gb_female: 30206000 }]
We set as many series as sectors. Let's color them in the corresponding colors, and also for the convenience of setting further options, we will add the male tag to the series displaying data on men. series:[{ name: "- ", valueField: "usa_male", color: "#9B30FF", tag: "male" },{ name: "- ", valueField: "usa_female", color: "#7D26CD" },{ name: "- ", valueField: "brazil_male", color: "#1E90FF", tag: "male" },{ name: "- ", valueField: "brazil_female", color: "#1874CD" },{ name: "- ", valueField: "rus_male", color: "#54FF9F", tag: "male" },{ name: "- ", valueField: "rus_female", color: "#43CD80" },{ name: "- ", valueField: "japan_male", color: "#FF6A6A", tag: "male" },{ name: "- ", valueField: "japan_female", color: "#CD5555" },{ name: "- ", valueField: "ger_male", color: "#FF7F24", tag: "male" },{ name: "- ", valueField: "ger_female", color: "#CD661D" },{ name: "- ", valueField: "gb_male", color: "#FFC125", tag: "male" },{ name: "- ", valueField: "gb_female", color: "#CD9B1D" }]
Each of these series has a stackedbar type. Almost all of them have a label showing the name of the country. Let's set these options for all series: commonSeriesSettings: { type: "stackedbar", label: { visible: true, font: { size: 14 }, customizeText: function(label){ return label.argumentText; } } }
Now labels will be shown in all sectors, and we need them only for the upper ones, which display data on women. This is where our male tag comes in, which we added to the series. Disable labels from the series that have this tag: customizeLabel: function(label) { if (label.series.tag === "male") { return { visible: false } } }
We describe the title: title: " "
Disable the legend: legend: { visible: false }
Disable all axes, because we don’t need them here. The axis of the arguments then has the form: argumentAxis: { visible: false, label: { visible: false }, grid: { visible: false }, tick: { visible: false } }
On the value axis, we also disable the upper indents using the valueMarginsEnabled option: valueAxis: { valueMarginsEnabled: false, visible: false, label: { visible: false }, grid: { visible: false }, minorGrid: { visible: false } }
Great, it only remains to figure out the tooltip tooltip . Turn it on and paint it in the color of the dot above which it pops up. To do this, use the customizeTooltip option. Since the population is measured in millions, so as not to show such large numbers, the format millions is applicable to it. We also describe that the tooltip contains information about all points on the argument, that is, regardless of whether the pointer is pointing at men or women, all information will be displayed. For this, we use the shared option. Then the tooltip options will be like this: tooltip: { enabled: true, shared: true, font: { color: "#FFFFFF", size: 14 }, format: "millions", customizeTooltip: function(arg) { return { color: arg.point.getColor(), borderColor: arg.point.getColor() } } }
options = { title: " ", dataSource:[{ arg:"", usa_male: 134782000, usa_female: 140786000 },{ arg: "", brazil_male: 85127000, brazil_female: 87730000 },{ arg: "", rus_male: 68278000, rus_female: 64750000 },{ arg: "", japan_male: 52387000, japan_female: 64586000 },{ arg: "", ger_male: 40450000, ger_female: 42344000 },{ arg: "", gb_male: 23486000, gb_female: 30206000 }], commonSeriesSettings: { type: "stackedbar", label: { visible: true, font: { size: 14 }, customizeText: function(label){ return label.argumentText; } } }, series:[{ name: "- ", valueField: "usa_male", color: "#9B30FF", tag: "male" },{ name: "- ", valueField: "usa_female", color: "#7D26CD" },{ name: "- ", valueField: "brazil_male", color: "#1E90FF", tag: "male" },{ name: "- ", valueField: "brazil_female", color: "#1874CD" },{ name: "- ", valueField: "rus_male", color: "#54FF9F", tag: "male" },{ name: "- ", valueField: "rus_female", color: "#43CD80" },{ name: "- ", valueField: "japan_male", color: "#FF6A6A", tag: "male" },{ name: "- ", valueField: "japan_female", color: "#CD5555" },{ name: "- ", valueField: "ger_male", color: "#FF7F24", tag: "male" },{ name: "- ", valueField: "ger_female", color: "#CD661D" },{ name: "- ", valueField: "gb_male", color: "#FFC125", tag: "male" },{ name: "- ", valueField: "gb_female", color: "#CD9B1D" }], legend: { visible: false }, argumentAxis: { visible: false, label: { visible: false }, grid: { visible: false }, tick: { visible: false } }, valueAxis: { valueMarginsEnabled: false, visible: false, label: { visible: false }, grid: { visible: false }, minorGrid: { visible: false } }, customizeLabel: function(label) { if (label.series.tag === "male") { return { visible: false } } }, tooltip: { enabled: true, shared: true, font: { color: "#FFFFFF", size: 14 }, format: "millions", customizeTooltip: function(arg) { return { color: arg.point.getColor(), borderColor: arg.point.getColor() } } } }
Source: https://habr.com/ru/post/244359/
All Articles