Skip to content

Commit 4810b48

Browse files
docs(chart): bubble chart
1 parent 9662891 commit 4810b48

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

components/chart/types/bubble.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: Bubble
3+
page_title: Chart for Blazor | Bubble
4+
description: Overview of the Bubble Chart for Blazor
5+
slug: components/chart/types/bubble
6+
tags: telerik,blazor,chart,bubble
7+
published: True
8+
position: 0
9+
---
10+
11+
# Bubble Chart
12+
13+
A **Bubble** chart shows the data as points with coordinates and size defined by their items' values. You might think of a Bubble chart as a variation of the [Scatter chart]({%slug components/chart/types/scatter%}), in which the data points are replaced with bubbles. This allows a Bubble chart to display three dimensional data — two values for the items' coordinates and one for their size.
14+
15+
A Bubble chart is useful for visualizing different scientific relationships (e.g, economical, social, etc.). This chart type's x-axis is also numerical and does not require items.
16+
17+
>caption Bubble chart. Results from the first code snippet below
18+
19+
![](images/basic-bubble-chart.png)
20+
21+
@[template](/_contentTemplates/chart/link-to-basics.md#understand-basics-and-databinding-first)
22+
23+
To create a bubble chart:
24+
25+
1. add a `ChartSeries` to the `ChartSeriesItems` collection
26+
2. set its `Type` property to `ChartSeriesType.Bubble`
27+
3. provide a data collection to its `Data` property, which contains numerical data for the X and Y axes, and for the buble size
28+
29+
30+
>caption A bubble chart that shows projected population change on a plot of life expectancy versus fertility rate
31+
32+
````CSHTML
33+
@* Bubble Series *@
34+
35+
<TelerikChart>
36+
37+
<ChartSeriesItems>
38+
<ChartSeries Type="ChartSeriesType.Bubble"
39+
Data="@Series1Data"
40+
Name="North America"
41+
XField="@nameof(ModelData.LifeExpectancy)"
42+
YField="@nameof(ModelData.FertilityRate)"
43+
SizeField="@nameof(ModelData.PopulationChange)">
44+
<ChartSeriesLabels Visible="true" Template="@labelTemplate"></ChartSeriesLabels>
45+
</ChartSeries>
46+
<ChartSeries Type="ChartSeriesType.Bubble"
47+
Data="@Series2Data"
48+
Name="Europe"
49+
XField="@nameof(ModelData.LifeExpectancy)"
50+
YField="@nameof(ModelData.FertilityRate)"
51+
SizeField="@nameof(ModelData.PopulationChange)">
52+
<ChartSeriesLabels Visible="true" Template="@labelTemplate"></ChartSeriesLabels>
53+
</ChartSeries>
54+
</ChartSeriesItems>
55+
56+
<ChartXAxes>
57+
<ChartXAxis>
58+
<ChartXAxisTitle Text="Life Expectancy (years)"></ChartXAxisTitle>
59+
</ChartXAxis>
60+
</ChartXAxes>
61+
62+
<ChartYAxes>
63+
<ChartYAxis>
64+
<ChartYAxisTitle Text="Fertility Rate (children per family)"></ChartYAxisTitle>
65+
</ChartYAxis>
66+
</ChartYAxes>
67+
68+
<ChartTitle Text="Life expectancy, fertility rate and projected population change" />
69+
70+
</TelerikChart>
71+
72+
@code {
73+
string labelTemplate = "#=dataItem.Country#";
74+
75+
public class ModelData
76+
{
77+
public double LifeExpectancy { get; set; }
78+
public double FertilityRate { get; set; }
79+
public int PopulationChange { get; set; }
80+
public string Country { get; set; }
81+
}
82+
83+
public List<ModelData> Series1Data = new List<ModelData>()
84+
{
85+
new ModelData() { LifeExpectancy = 80.66, FertilityRate = 1.27, PopulationChange = 500000, Country = "Canada" },
86+
new ModelData() { LifeExpectancy = 78.09, FertilityRate = 2.3, PopulationChange = 7600000, Country = "USA" }
87+
};
88+
89+
public List<ModelData> Series2Data = new List<ModelData>()
90+
{
91+
new ModelData() { LifeExpectancy = 67.3, FertilityRate = 1.54, PopulationChange = 25000, Country = "Denmark" },
92+
new ModelData() { LifeExpectancy = 74.3, FertilityRate = 1.85, PopulationChange = 3000000, Country = "Great Britain" }
93+
};
94+
}
95+
96+
````
97+
98+
99+
## Bubble Chart Specific Appearance Settings
100+
101+
### Color
102+
103+
The color of a series is controlled through the `Color` property that can take any valid CSS color (for example, `#abcdef`, `#f00`, or `blue`). The color control the fill color of the bubble.
104+
105+
<!--
106+
107+
### Opacity
108+
109+
You can control how transparent the bubble fill is through the `Opacity` property. `0` means a completely opaque (non-transparent) series, and `255` means a completely transparent fill.
110+
111+
-->
112+
113+
114+
<!--
115+
### Negative Values
116+
117+
Negative values are allowed for the X and Y fields, because they are plotted on standard numerical axes.
118+
119+
The size field should, generally, have positive values as it correlates to the physical size of the bubble. To render negativ values, set the `NegativeValuesVisible` parameter of the series to `true`. They will be calculated as if their values are positive. To distinguish one from the other, you can have negative items show up in a different color through the `NegativeColor` parameter of the serires.
120+
121+
-->
122+
123+
## See Also
124+
125+
* [Live Demo: Area Chart](https://demos.telerik.com/blazor-ui/chart/area-chart)
17.3 KB
Loading

0 commit comments

Comments
 (0)