sky/assets/demo/demo.js

178 lines
4.6 KiB
JavaScript
Raw Normal View History

2021-07-25 09:12:40 +08:00
demo = {
initDocChart: function() {
chartColor = "#FFFFFF";
// General configuration for the charts with Line gradientStroke
gradientChartOptionsConfiguration = {
maintainAspectRatio: false,
legend: {
display: false
},
tooltips: {
bodySpacing: 4,
mode: "nearest",
intersect: 0,
position: "nearest",
xPadding: 10,
yPadding: 10,
caretPadding: 10
},
responsive: true,
scales: {
yAxes: [{
display: 0,
gridLines: 0,
ticks: {
display: false
},
gridLines: {
zeroLineColor: "transparent",
drawTicks: false,
display: false,
drawBorder: false
}
}],
xAxes: [{
display: 0,
gridLines: 0,
ticks: {
display: false
},
gridLines: {
zeroLineColor: "transparent",
drawTicks: false,
display: false,
drawBorder: false
}
}]
},
layout: {
padding: {
left: 0,
right: 0,
top: 15,
bottom: 15
}
}
};
ctx = document.getElementById('lineChartExample').getContext("2d");
gradientStroke = ctx.createLinearGradient(500, 0, 100, 0);
gradientStroke.addColorStop(0, '#80b6f4');
gradientStroke.addColorStop(1, chartColor);
gradientFill = ctx.createLinearGradient(0, 170, 0, 50);
gradientFill.addColorStop(0, "rgba(128, 182, 244, 0)");
gradientFill.addColorStop(1, "rgba(249, 99, 59, 0.40)");
myChart = new Chart(ctx, {
type: 'line',
responsive: true,
data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: [{
label: "Active Users",
borderColor: "#f96332",
pointBorderColor: "#FFF",
pointBackgroundColor: "#f96332",
pointBorderWidth: 2,
pointHoverRadius: 4,
pointHoverBorderWidth: 1,
pointRadius: 4,
fill: true,
backgroundColor: gradientFill,
borderWidth: 2,
data: [542, 480, 430, 550, 530, 453, 380, 434, 568, 610, 700, 630]
}]
},
options: gradientChartOptionsConfiguration
});
},
initLandingPageChart: function() {
var ctx = document.getElementById('chartBig').getContext("2d");
var gradientFill = ctx.createLinearGradient(0, 350, 0, 50);
gradientFill.addColorStop(0, "rgba(228, 76, 196, 0.0)");
gradientFill.addColorStop(1, "rgba(228, 76, 196, 0.14)");
var chartBig = new Chart(ctx, {
type: 'line',
responsive: true,
data: {
labels: ["JUN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"],
datasets: [{
label: "Data",
fill: true,
backgroundColor: gradientFill,
borderColor: '#e44cc4',
borderWidth: 2,
borderDash: [],
borderDashOffset: 0.0,
pointBackgroundColor: '#e44cc4',
pointBorderColor: 'rgba(255,255,255,0)',
pointHoverBackgroundColor: '#be55ed',
//pointHoverBorderColor:'rgba(35,46,55,1)',
pointBorderWidth: 20,
pointHoverRadius: 4,
pointHoverBorderWidth: 15,
pointRadius: 4,
data: [80, 160, 200, 160, 250, 280, 220, 190, 200, 250, 290, 320]
}]
},
options: {
maintainAspectRatio: false,
legend: {
display: false
},
tooltips: {
backgroundColor: '#fff',
titleFontColor: '#ccc',
bodyFontColor: '#666',
bodySpacing: 4,
xPadding: 12,
mode: "nearest",
intersect: 0,
position: "nearest"
},
responsive: true,
scales: {
yAxes: [{
barPercentage: 1.6,
gridLines: {
drawBorder: false,
color: 'rgba(0,0,0,0.0)',
zeroLineColor: "transparent",
},
ticks: {
display: false,
suggestedMin: 0,
suggestedMax: 350,
padding: 20,
fontColor: "#9a9a9a"
}
}],
xAxes: [{
barPercentage: 1.6,
gridLines: {
drawBorder: false,
color: 'rgba(0,0,0,0)',
zeroLineColor: "transparent",
},
ticks: {
padding: 20,
fontColor: "#9a9a9a"
}
}]
}
}
});
}
}