Comments (4)
With some carefull own logic with creating the bubbles you could create this already using a bubble chart. But if you want it as an chart type that does that logic for you I think it would suit better as an external chart type and not something for the core
from chart.js.
With some carefull own logic with creating the bubbles you could create this already using a bubble chart. But if you want it as an chart type that does that logic for you I think it would suit better as an external chart type and not something for the core
agreed, it's probably not core. I've got close using the sample I linked, but getting the returned X,Y, and Radius scaled to fit into the canvas is making my head hurt! Sample code here in case it's of use to anyone (and hopefully someone points to where I'm going wrong) - at the moment there's still sometimes gaps or overlay of the circles that I don't see in the jsfiddle, and bubbles get clipped at the edge of the canvas.
<canvas id="canvas" style="width:450px; height:450px;"></canvas>
// include the calculation code from https://jsfiddle.net/TDzVE/
var radiuses = [];
for(var i=0; i<15; i++) {
radiuses.push(Math.random() * (200) + 1)
}
var packer = new Packer (radiuses, 1);
var chart = $("#canvas")
var margin_factor = 0.1;
var mx = chart.width() * margin_factor / 2;
var my = chart.height() * margin_factor / 2;
dx=Number(packer.w)/2
dy=Number(packer.h)/2
var zx = chart.width() / packer.w;
var zy = chart.height() / packer.h;
var zoom = zx < zy ? zx : zy;
datapoints = [];
for (var i=0; i<packer.list.length;i++) {
circle = packer.list[i]
datapoints.push({'x':(circle.c.x+dx)*zoom+mx, 'y':(circle.c.y+dy)*zoom+my, 'r':circle.r*zoom})
}
const data = {
datasets: [
{
label: 'Dataset 1',
data: datapoints,
backgroundColor: "rgba(123,123,123,1)",
},
]
};
var myBarChart = new Chart(chart, {
type: 'bubble',
data: data,
options: {
responsive : false,
maintainAspectRatio : true,
layout : {
autoPadding : false,
},
scales: {
x: {
ticks: {display: false,},
grid: { display: false },
border: {display: false}
},
y: {display:false,
ticks: {display: false,},
grid: { display: false, },
border: {display: false}
}
},
plugins: {
legend: {display: false,},
title: {display: false,}
}
},
})
from chart.js.
another, clunky, solution using the D3 v3 layout.pack algorithm https://stackoverflow.com/a/76911169/1569675
from chart.js.
Would love this as well
from chart.js.
Related Issues (20)
- Chart.js packages documentation along with actual source code, bloating node_modules HOT 1
- Funnel Chart Please HOT 2
- Doughnut chart has an active element when hovering out
- Label font style not rendering due to having some 'null' points in the array.
- Line chart type time data is being grouped incorrectly
- CDN version of the plain (esm) chart.js cannot be imported? HOT 8
- Bottom line under 0 (zero) is drawn in line chart but shouldn't if tick beginAtZero is set to 0
- "pie": Runtime errors when setting legend position to "left" or "right" HOT 5
- Tick stepSize error HOT 2
- local Chart (chart.js / chart.min.js) HOT 1
- #4.x.x / About chart area zero line HOT 1
- Type error with BubbleDataPoint when using ChartData<'bubble'>
- Type error with font weight as a number
- Polar line plot
- Add boolean property to match the Datalabels color with the corresponding line/bar color HOT 2
- Type error related to 'cutout' in chart options
- How to create custom legend/ How to provide line break in the legend if it is long text?
- 2 Bar and 2 Line chart are not aligning with each other. HOT 2
- TimePoint support for time series HOT 1
- Resposive chart infinitely shrinking with certain zoom levels HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chart.js.