Skip to content

Commit 0d72720

Browse files
dimodiyordan-mitev
andauthored
docs(Chart): Add information about CSS variables (#2744)
* docs(Chart): Add information about CSS variables * Update components/chart/overview.md Co-authored-by: Yordan <60105689+yordan-mitev@users.noreply.github.com> * edit heading --------- Co-authored-by: Yordan <60105689+yordan-mitev@users.noreply.github.com>
1 parent 7d1eed2 commit 0d72720

File tree

2 files changed

+94
-12
lines changed

2 files changed

+94
-12
lines changed

components/chart/overview.md

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ The <a href="https://www.telerik.com/blazor-ui/chart" target="_blank">Blazor Cha
2222
>caption Basic chart
2323
2424
````RAZOR
25-
Basic chart and common settings/elements
26-
2725
<TelerikChart>
2826
<ChartSeriesItems>
2927
<ChartSeries Type="ChartSeriesType.Line" Name="Product 1 (bound to simple data)" Data="@simpleData">
@@ -55,7 +53,7 @@ Basic chart and common settings/elements
5553
}
5654
5755
public List<MyDataModel> modelData = new List<MyDataModel>()
58-
{
56+
{
5957
new MyDataModel() { SecondSeriesValue = 1, ExtraData = "first" },
6058
new MyDataModel() { SecondSeriesValue = 5, ExtraData = "second" },
6159
new MyDataModel() { SecondSeriesValue = 3, ExtraData = "third" },
@@ -72,25 +70,28 @@ Basic chart and common settings/elements
7270

7371
@[template](/_contentTemplates/chart/link-to-basics.md#configurable-nested-chart-settings)
7472

75-
## Chart Title
73+
## Title and Subtitle
7674

7775
You can add a short description of the Chart's purpose by using the `ChartTitle` tag and the `Text` parameter. In addition, the `ChartTitle` `Description` parameter allows the app to provide accessible text content, which screen readers announce when the Chart gains focus.
7876

79-
>caption Using ChartTitle
77+
You can also add a secondary title through `ChartSubtitle` and configure its `Position`.
78+
79+
>caption Using Chart Title, Description and
8080
8181
<div class="skip-repl"></div>
8282

8383
````RAZOR
8484
<TelerikChart>
85-
<ChartTitle Text="Product Sales" Description="Product Sales by Year and Country"></ChartTitle>
85+
<ChartTitle Text="Product Sales"
86+
Description="Product Sales by Year and Country"
87+
Position="@ChartTitlePosition.Top">
88+
<ChartSubtitle Text="Product Sales by Year and Country"
89+
Position="@ChartSubtitlePosition.Bottom" />
90+
</ChartTitle>
8691
</TelerikChart>
8792
````
8893

89-
## Chart Subtitle
90-
91-
You can add a descriptive text that enriches the [Title](#chart-title) by adding the `ChartSubtitle` and assigning a value for the `Text` parameter.
92-
93-
## Chart Size
94+
## Size
9495

9596
To control the chart size, use its `Width` and `Height` properties. You can read more on how they work in the [Dimensions](slug://common-features/dimensions) article.
9697

@@ -145,6 +146,87 @@ You can make a responsive chart
145146
}
146147
````
147148

149+
## Styling with CSS Variables
150+
151+
The Chart allows various [customizations through child tags and parameters](#chart-elements). Starting with version 7.2.0, the Chart also supports visual customizations through [CSS variables](slug:themes-customize#setting-theme-variables).
152+
153+
>caption Using CSS variables to customize the Chart appearance
154+
155+
````RAZOR
156+
<style>
157+
/* All Charts */
158+
div.k-chart {
159+
/* Chart background */
160+
--kendo-chart-bg: #ffd;
161+
/* Chart text */
162+
--kendo-chart-text: #f00;
163+
/* First series color. Supports up to --kendo-chart-series-30 */
164+
--kendo-chart-series-1: #f93;
165+
}
166+
167+
/* Charts with this CSS class */
168+
div.lime-chart {
169+
/* Chart background */
170+
--kendo-chart-bg: #dfd;
171+
/* Chart text */
172+
--kendo-chart-text: #00f;
173+
/* First series color. Supports up to --kendo-chart-series-30 */
174+
--kendo-chart-series-1: #39f;
175+
}
176+
</style>
177+
178+
<div style="display: flex; gap: 2em;">
179+
<TelerikChart Height="240px"
180+
Width="400px">
181+
<ChartTitle Text="Chart" />
182+
<ChartSeriesItems>
183+
<ChartSeries Type="ChartSeriesType.Column"
184+
Data="@ChartData"
185+
Field="@nameof(SalesData.Revenue)"
186+
CategoryField="@nameof(SalesData.Product)">
187+
</ChartSeries>
188+
</ChartSeriesItems>
189+
</TelerikChart>
190+
191+
<TelerikChart Class="lime-chart"
192+
Height="240px"
193+
Width="400px">
194+
<ChartTitle Text="Chart" />
195+
<ChartSeriesItems>
196+
<ChartSeries Type="ChartSeriesType.Column"
197+
Data="@ChartData"
198+
Field="@nameof(SalesData.Revenue)"
199+
CategoryField="@nameof(SalesData.Product)">
200+
</ChartSeries>
201+
</ChartSeriesItems>
202+
</TelerikChart>
203+
</div>
204+
205+
@code {
206+
private List<SalesData> ChartData { get; set; } = new();
207+
208+
protected override void OnInitialized()
209+
{
210+
var productCount = 3;
211+
212+
for (int i = 1; i <= productCount; i++)
213+
{
214+
ChartData.Add(new SalesData()
215+
{
216+
Product = $"Product {i}",
217+
Revenue = i * 4
218+
});
219+
}
220+
}
221+
222+
public class SalesData
223+
{
224+
public string Product { get; set; } = string.Empty;
225+
public decimal Revenue { get; set; }
226+
}
227+
}
228+
````
229+
148230
## Chart Parameters
149231

150232
The following table lists Chart parameters, which are not discussed elsewhere in the component documentation.

components/chart/rendering-modes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Using vector graphics ensures that:
2525
* The browser zoom does not degrade the image.
2626
* The prints are crisp regardless of the resolution.
2727

28-
In addition, the SVG Chart provides accessibility features such as [general description](slug://components/chart/overview#chart-title) and [aria label templates](slug://components/chart/label-template-format#series-label-aria-template) out of the box.
28+
In addition, the SVG Chart provides accessibility features such as [general description](slug://components/chart/overview#title-and-subtitle) and [aria label templates](slug://components/chart/label-template-format#series-label-aria-template) out of the box.
2929

3030
>caption Bar Chart rendered as SVG
3131

0 commit comments

Comments
 (0)