-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathSnippets.demosnippets
88 lines (55 loc) · 2.01 KB
/
Snippets.demosnippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
TAB: Creating & running RCL
- <link> to CSS file
<link href="_content/BlazorChartist/styles.css" rel="stylesheet" />
TAB: Wrapping 3rd party JS
- Whole Chart.razor contents making JS interop call
<div @ref="elem" class="ct-chart"></div>
@inject IJSRuntime JS
@code {
ElementReference elem;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JS.InvokeVoidAsync("BlazorChartist.createChart", elem);
}
}
}
TAB: Defining an API
- private ChartData sampleData = ...
@code {
private static string[] labels = new[] { "Jan", "Feb", "Mar", "Apr", "May" };
private static double[] oilPrices = new double[] { 51, 55, 68, 52, 51 };
private static double[] trumpTweets = new double[] { 35, 19, 26, 68, 21 };
private ChartData sampleData = new ChartData
{
Labels = labels,
Series = new List<SeriesData>
{
new SeriesData { Name = "Crude oil price ($)", Data = oilPrices },
new SeriesData { Name = "Trump tweets", Data = trumpTweets },
}
};
}
- Two uses of <Chart />
<Chart Type="ChartType.Bar" Data="@sampleData" />
<Chart Type="ChartType.Line" Data="@sampleData" />
TAB: Designing a better API
- bool showTrumpTweets = true;
bool showTrumpTweets = true;
- <input type="checkbox" @bind="showTrumpTweets" />
<input type="checkbox" @bind="showTrumpTweets" />
- title="Graph of oil vs tweets" style="background-color: lightyellow;"
title="Graph of oil vs tweets" style="background-color: lightyellow;"
- [Parameter] with CaptureUnmatchedValues
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> ExtraAttributes { get; set; }
- @attributes="@ExtraAttributes"
@attributes="@ExtraAttributes"
TAB: Adding XML docs
- Summary text for <Series> class
Adds a data series to the enclosing <see cref="Chart"/> component.
- Summary text for Labels prop
Specifies X-axis (catergory) labels.
TAB: Ensuring compatibility
TAB: Adding a Webpack build
TAB: CI/CD