ChartAct / web /Chart.js /line /chart_0062_line.html
wumumu's picture
Add files using upload-large-folder tool
dae061a verified
Raw History Blame Contribute Delete
5.92 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Line Chart Datasets</title>
<style>
:root {
color-scheme: light;
}
body {
margin: 0;
padding: 20px;
font-family: Segoe UI, Arial, sans-serif;
background: #f5f7fb;
color: #1f2a37;
}
h1 {
margin: 0 0 10px 0;
font-size: 20px;
font-weight: 600;
}
#legend-container {
margin-bottom: 8px;
}
#chart-wrap {
position: relative;
width: min(1100px, 100%);
height: 520px;
background: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 10px;
padding: 12px;
box-sizing: border-box;
}
#chart {
width: 100%;
height: 100%;
}
</style>
<script src="./luxon.min.js"></script>
<script src="./chart.umd.min.js"></script>
<script src="./chartjs-adapter-luxon.umd.min.js"></script>
</head>
<body>
<h1>Line Chart Datasets</h1>
<div id="legend-container"></div>
<div id="chart-wrap">
<canvas id="chart"></canvas>
</div>
<script type="text/plain" data-chart-inline="true">
const inputs = {
min: 20,
max: 80,
count: 8,
decimals: 2,
continuity: 1
};
const generateLabels = () => {
return ["January", "February", "March", "April", "May", "June", "July", "August"];
};
const __generatedDataValues = [[73.15, 77.54, 53.72, 55.76, 62.18, 62.62, 64.47, 79.6], [30.96, 59.3, 29.79, 38.75, 60.23, 52.77, 45.98, 27.28], [48.52, 72.66, 40.44, 37.05, 78.78, 59.71, 38.36, 24.35], [45.09, 72.44, 49.36, 76.58, 39.3, 53.81, 54.19, 78.94], [57.71, 57.9, 31.36, 21.06, 47.73, 36.56, 23.85, 43.66], [54.53, 26.08, 65.71, 45.28, 47.76, 73.87, 28.81, 48.88], [28.14, 25.12, 49.44, 68.52, 54.2, 69.45, 35.01, 76.07], [68.91, 67.62, 50.71, 67.81, 66.33, 58.13, 26.15, 51.16], [58.32, 23.94, 42.09, 71.3, 21.18, 59.14, 57.05, 37.85], [62.3, 35.58, 33.98, 71.57, 26.88, 29.54, 46.95, 50.97]];
let __generatedDataIndex = 0;
function generateData() {
const value = __generatedDataValues[__generatedDataIndex] ?? __generatedDataValues[__generatedDataValues.length - 1];
__generatedDataIndex += 1;
return JSON.parse(JSON.stringify(value));
}
Utils.srand(42);
const data = {
labels: generateLabels(),
datasets: [
{
label: 'D0',
data: generateData(),
borderColor: Utils.CHART_COLORS.red,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.red),
hidden: true
},
{
label: 'D1',
data: generateData(),
borderColor: Utils.CHART_COLORS.orange,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.orange),
fill: '-1'
},
{
label: 'D2',
data: generateData(),
borderColor: Utils.CHART_COLORS.yellow,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.yellow),
hidden: true,
fill: 1
},
{
label: 'D3',
data: generateData(),
borderColor: Utils.CHART_COLORS.green,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.green),
fill: '-1'
},
{
label: 'D4',
data: generateData(),
borderColor: Utils.CHART_COLORS.blue,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.blue),
fill: '-1'
},
{
label: 'D5',
data: generateData(),
borderColor: Utils.CHART_COLORS.grey,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.grey),
fill: '+2'
},
{
label: 'D6',
data: generateData(),
borderColor: Utils.CHART_COLORS.purple,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.purple),
fill: false
},
{
label: 'D7',
data: generateData(),
borderColor: Utils.CHART_COLORS.red,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.red),
fill: 8
},
{
label: 'D8',
data: generateData(),
borderColor: Utils.CHART_COLORS.orange,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.orange),
fill: 'end',
hidden: true
},
{
label: 'D9',
data: generateData(),
borderColor: Utils.CHART_COLORS.yellow,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.yellow),
fill: {above: 'blue', below: 'red', target: {value: 350}}
}
]
};
const config = {
type: 'line',
data: data,
options: {
scales: {
y: {
stacked: true
}
},
plugins: {
filler: {
propagate: false
},
'samples-filler-analyser': {
target: 'chart-analyser'
}
},
interaction: {
intersect: false,
},
},
};
function forceEnableHoverTooltip(chartConfig) {
if (!chartConfig || typeof chartConfig !== 'object') {
return;
}
if (!chartConfig.options || typeof chartConfig.options !== 'object') {
chartConfig.options = {};
}
const options = chartConfig.options;
if (!options.plugins || typeof options.plugins !== 'object') {
options.plugins = {};
}
const plugins = options.plugins;
if (plugins.tooltip === false) {
plugins.tooltip = {};
}
if (!plugins.tooltip || typeof plugins.tooltip !== 'object') {
plugins.tooltip = {};
}
const hasExternalTooltip = typeof plugins.tooltip.external === 'function';
if (!hasExternalTooltip) {
plugins.tooltip.enabled = true;
}
}
forceEnableHoverTooltip(config);
const sampleCanvas = document.getElementById('chart');
const sampleChart = new Chart(sampleCanvas, config);
</script>
<script src="./chart_0062_line.inline01.js"></script>
</body>
</html>