ekoetki/public/assets/js/boxplot.js

339 lines
6.0 KiB
JavaScript

// **------ boxplot chart 1**
const boxplot1ChartOption = {
series: [
{
type: 'boxPlot',
data: [
{
x: 'Jan 2015',
y: [54, 66, 69, 75, 88]
},
{
x: 'Jan 2016',
y: [43, 65, 69, 76, 81]
},
{
x: 'Jan 2017',
y: [31, 39, 45, 51, 59]
},
{
x: 'Jan 2018',
y: [39, 46, 55, 65, 71]
},
{
x: 'Jan 2019',
y: [29, 31, 35, 39, 44]
},
{
x: 'Jan 2020',
y: [41, 49, 58, 61, 67]
},
{
x: 'Jan 2021',
y: [54, 59, 66, 71, 88]
}
]
}
],
chart: {
fontFamily: "Rubik, serif",
type: 'boxPlot',
height: 350
},
title: {
text: '',
align: 'left'
},
plotOptions: {
boxPlot: {
colors: {
upper: getLocalStorageItem('color-primary','#0F626A'),
lower: getLocalStorageItem('color-secondary','#626262')
}
}
},
xaxis: {
labels: {
style: {
colors: [],
fontSize: '14px',
fontWeight: 500,
},
},
},
yaxis: {
labels: {
style: {
colors: [],
fontSize: '14px',
fontWeight: 500,
},
},
},
grid: {
show: true,
borderColor: 'rgba(var(--dark),.2)',
strokeDashArray: 2,
xaxis: {
lines: {
show: false
}
},
yaxis: {
lines: {
show: true
},
}
},
tooltip: {
x: {
show: false,
},
style: {
fontSize: '16px',
},
},
};
const boxplot1Chart = new ApexCharts(document.querySelector("#boxplot1"), boxplot1ChartOption);
boxplot1Chart.render();
// **------boxplot chart 2**
const boxplot2ChartOption = {
series: [
{
name: 'box',
type: 'boxPlot',
data: [
{
x: new Date('2017-01-01').getTime(),
y: [54, 66, 69, 75, 88]
},
{
x: new Date('2018-01-01').getTime(),
y: [43, 65, 69, 76, 81]
},
{
x: new Date('2019-01-01').getTime(),
y: [31, 39, 45, 51, 59]
},
{
x: new Date('2020-01-01').getTime(),
y: [39, 46, 55, 65, 71]
},
{
x: new Date('2021-01-01').getTime(),
y: [29, 31, 35, 39, 44]
}
]
},
{
name: 'outliers',
type: 'scatter',
data: [
{
x: new Date('2017-01-01').getTime(),
y: 32
},
{
x: new Date('2018-01-01').getTime(),
y: 25
},
{
x: new Date('2019-01-01').getTime(),
y: 64
},
{
x: new Date('2020-01-01').getTime(),
y: 27
},
{
x: new Date('2020-01-01').getTime(),
y: 78
},
{
x: new Date('2021-01-01').getTime(),
y: 15
}
]
}
],
chart: {
fontFamily: "Rubik, serif",
type: 'boxPlot',
height: 350
},
title: {
text: '',
align: 'left'
},
xaxis: {
type: 'datetime',
tooltip: {
formatter: function(val) {
return new Date(val).getFullYear()
}
},
labels: {
style: {
colors: [],
fontSize: '14px',
fontWeight: 500,
},
},
},
yaxis: {
labels: {
style: {
colors: [],
fontSize: '14px',
fontWeight: 500,
},
},
},
plotOptions: {
boxPlot: {
colors: {
upper: '#0AB964',
lower: '#E14E5A'
}
}
},
grid: {
show: true,
borderColor: 'rgba(var(--dark),.2)',
strokeDashArray: 2,
xaxis: {
lines: {
show: false
}
},
yaxis: {
lines: {
show: true
},
}
},
tooltip: {
shared: false,
intersect: true,
x: {
show: false,
},
style: {
fontSize: '16px',
},
},
};
const boxplot2Chart = new ApexCharts(document.querySelector("#boxplot2"), boxplot2ChartOption);
boxplot2Chart.render();
// **------boxplot chart 3**
const boxplot3ChartOption = {
series: [
{
data: [
{
x: 'Category A',
y: [54, 66, 69, 75, 88]
},
{
x: 'Category B',
y: [43, 65, 69, 76, 81]
},
{
x: 'Category C',
y: [31, 39, 45, 51, 59]
},
{
x: 'Category D',
y: [39, 46, 55, 65, 71]
},
{
x: 'Category E',
y: [29, 31, 35, 39, 44]
},
{
x: 'Category F',
y: [41, 49, 58, 61, 67]
},
{
x: 'Category G',
y: [54, 59, 66, 71, 88]
}
]
}
],
chart: {
fontFamily: "Rubik, serif",
type: 'boxPlot',
height: 350
},
title: {
text: '',
align: 'left'
},
plotOptions: {
bar: {
horizontal: true,
barHeight: '50%'
},
boxPlot: {
colors: {
upper: '#F9C123',
lower: '#4196FA'
}
}
},
xaxis: {
labels: {
style: {
colors: [],
fontSize: '14px',
fontWeight: 500,
},
},
},
yaxis: {
labels: {
style: {
colors: [],
fontSize: '14px',
fontWeight: 500,
},
},
},
grid: {
show: true,
borderColor: 'rgba(var(--dark),.2)',
strokeDashArray: 2,
xaxis: {
lines: {
show: false
}
},
yaxis: {
lines: {
show: true
},
}
},
tooltip: {
x: {
show: false,
},
style: {
fontSize: '16px',
},
},
stroke: {
colors: ['#6c757d']
}
};
const boxplot3Chart = new ApexCharts(document.querySelector("#boxplot3"), boxplot3ChartOption);
boxplot3Chart.render();