ChartAct / web /Chart.js /scatter /chart_0050_scatter.html
wumumu's picture
Add files using upload-large-folder tool
dae061a verified
Raw History Blame Contribute Delete
3.75 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bubble</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>Bubble</h1>
<div id="legend-container"></div>
<div id="chart-wrap">
<canvas id="chart"></canvas>
</div>
<script type="text/plain" data-chart-inline="true">
const DATA_COUNT = 7;
const NUMBER_CFG = {count: DATA_COUNT, rmin: 5, rmax: 15, min: 0, max: 100};
const data = {
datasets: [
{
label: 'Dataset 1',
data: [{x: 57.13863169, y: 64.0736454, r: 14.436256858710562}, {x: 61.2598594, y: 95.86977023, r: 13.738254458161865}, {x: 4.78437929, y: 72.00745885, r: 11.61792695473251}, {x: 29.6875, y: 97.42498285, r: 10.451817558299041}, {x: 63.12971536, y: 40.02357682, r: 14.46832133058985}, {x: 28.5678155, y: 8.44521605, r: 11.969907407407408}, {x: 23.53266461, y: 96.51706104, r: 14.222007887517146}],
borderColor: Utils.CHART_COLORS.red,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.red, 0.5),
},
{
label: 'Dataset 2',
data: [{x: 60.08573388, y: 2.25737311, r: 12.272119341563787}, {x: 49.13494513, y: 60.95679012, r: 5.095207475994513}, {x: 34.37757202, y: 5.97307956, r: 12.637945816186557}, {x: 31.86299726, y: 27.42969822, r: 7.647247942386831}, {x: 87.2702332, y: 89.52417695, r: 9.166323731138545}, {x: 53.68569959, y: 74.97256516, r: 8.090234910836763}, {x: 36.04766804, y: 96.12054184, r: 9.388117283950617}],
borderColor: Utils.CHART_COLORS.orange,
backgroundColor: Utils.transparentize(Utils.CHART_COLORS.orange, 0.5),
}
]
};
const config = {
type: 'bubble',
data: data,
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'Chart.js Bubble Chart'
}
}
},
};
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_0050_scatter.inline01.js"></script>
</body>
</html>