mirror of
https://github.com/dolanmiu/docx.git
synced 2026-12-01 16:55:59 +01:00
4.1 KiB
4.1 KiB
Bubble Charts
A bubble chart is a scatter chart whose points are bubbles of different sizes, so it shows three numbers for each point: where it is across, where it is up, and how big it is.
Charts shows how to import ChartRun and add a chart to a document.
A Bubble Chart
new ChartRun({
type: "bubble",
title: "Markets",
series: [
{
name: "Europe",
points: [
{ x: 12, y: 4.5, size: 740 },
{ x: 18, y: 3.1, size: 330 },
],
},
{ name: "Asia", points: [{ x: 24, y: 6.8, size: 1400 }] },
],
xAxis: { title: "Market share (%)" },
yAxis: { title: "Growth (%)" },
});
- Like a scatter chart, a bubble chart has no categories. Each series has
points, and each point has anx, ayand asize. - Sizes are compared with each other: the biggest bubble is drawn at Office's largest size, and the others in proportion. They can't be negative.
- Bubbles are drawn in their series' colour, a quarter see-through, so bubbles behind them show.
Bubble Sizes
bubbleScalemakes every bubble bigger or smaller, as a percentage of Office's size, from0to300. The default is100.sizeRepresentssays whether a point'ssizeis the bubble's area ("area", the default) or its width ("width"). By area, a bubble of size 4 looks twice as wide as one of size 1; by width, four times as wide.
bubbleScale: 60,
sizeRepresents: "width",
Labels
A bubble's label can show its size, as well as what any label shows:
dataLabels: { bubbleSize: true },
See Chart Data Labels.
Options
| Property | Type | Notes | Description |
|---|---|---|---|
type |
"bubble" |
Required | |
series |
BubbleChartSeries[] |
Required | { name, points, color?, dataLabels? }, where a point is { x, y, size } |
bubbleScale |
number |
Optional | The bubbles' size, as a percentage of Office's, from 0 to 300. Default 100 |
sizeRepresents |
"area" | "width" |
Optional | Whether a size is a bubble's area or width. Default "area" |
xAxis |
ChartValueAxis |
Optional | The horizontal axis. See Chart Axes |
yAxis |
ChartValueAxis |
Optional | The vertical axis. See Chart Axes |
dataLabels |
BubbleChartDataLabels |
Optional | { value?, category?, seriesName?, bubbleSize?, ... }. See Chart Data Labels |
title |
string | ChartTitle |
Optional | See Chart Titles and Legends |
legend |
false | ChartLegend |
Optional | See Chart Titles and Legends |
transformation |
{ width, height } |
Optional | See Chart Size and Position |
floating |
IFloating |
Optional | See Chart Size and Position |
altText |
DocPropertiesOptions |
Optional | See Chart Size and Position |
Chart Fonts and Fills shows the options every chart has for its text, background and border.