Skip to content

Commit 9b7d65d

Browse files
authored
docs(Grid): update examples in kb articles (#2219)
* docs(Grid): update examples in kb articles * apply suggestion
1 parent 37a6cf4 commit 9b7d65d

File tree

2 files changed

+123
-32
lines changed

2 files changed

+123
-32
lines changed

knowledge-base/chart-draw-horizontal-vertical-lines.md

Lines changed: 88 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -109,52 +109,116 @@ Steps for drawing vertical and horizontal lines with [plot bands]({%slug chart-p
109109
}
110110
`````
111111

112-
### Using Additional Line Series
112+
### Using Additional ScatterLine Series
113113

114-
Steps for drawing horizontal and vertical lines with additional [Lines Series]({%slug components/chart/types/line%}):
114+
Steps for drawing horizontal and vertical lines with additional [ScatterLine Series]({%slug components/chart/types/scatterline%}):
115115

116-
1. Add `ChartSeries` instances of type `ChartSeriesType.Line` based on the needed number of lines.
116+
1. Add `ChartSeries` instances of type `ChartSeriesType.ScatterLine` based on the needed number of lines.
117117
2. Set data for the lines based on the information shown from the main Chart.
118118

119-
>caption Drawing Horizontal and Vertical lines with additional Lines Chart
119+
>caption Drawing Horizontal and Vertical lines with additional ScatterLine Chart
120120
121121
````CSHTML
122122
<TelerikChart>
123+
<ChartLegend Visible="true"></ChartLegend>
124+
123125
<ChartSeriesItems>
124-
<ChartSeries Type="ChartSeriesType.Column" Name="Column 1" Data="@firstColumnTypeData">
125-
</ChartSeries>
126-
<ChartSeries Type="ChartSeriesType.Column" Name="Column 2" Data="@secondColumnTypeData">
126+
<ChartSeries Type="ChartSeriesType.Scatter"
127+
Data="@SeriesScatterData"
128+
Name="Scatter"
129+
XField="@nameof(ModelData.X)"
130+
YField="@nameof(ModelData.Y)">
127131
</ChartSeries>
128-
<ChartSeries Type="ChartSeriesType.Line" Name="Line 1" Data="@firstLineTypeData">
132+
133+
<ChartSeries Type="ChartSeriesType.Bubble"
134+
Data="@SeriesBubbleData"
135+
Name="Bubble"
136+
XField="@nameof(ModelData.X)"
137+
YField="@nameof(ModelData.Y)"
138+
SizeField="@nameof(BubbleData.SizeField)">
129139
</ChartSeries>
130-
<ChartSeries Type="ChartSeriesType.Line" Name="Line 2" Data="@secondLineTypeData">
140+
141+
<ChartSeries Type="ChartSeriesType.ScatterLine"
142+
Data="@Series1Data"
143+
Name="Line"
144+
XField="@nameof(ModelData.X)"
145+
YField="@nameof(ModelData.Y)">
146+
<ChartSeriesMarkers Visible="false" />
131147
</ChartSeries>
132-
</ChartSeriesItems>
133148
134-
<ChartCategoryAxes>
135-
<ChartCategoryAxis Categories="@xColumnAxisItems"></ChartCategoryAxis>
136-
</ChartCategoryAxes>
149+
<ChartSeries Type="ChartSeriesType.ScatterLine"
150+
Data="@Series2Data"
151+
Name="Dashed Line"
152+
XField="@nameof(ModelData.X)"
153+
YField="@nameof(ModelData.Y)"
154+
DashType="@DashType.Dash">
155+
<ChartSeriesMarkers Visible="false" />
156+
</ChartSeries>
137157
138-
<ChartTitle Text="Draw Horizontal and Vertical Lines"></ChartTitle>
158+
<ChartSeries Type="ChartSeriesType.ScatterLine"
159+
Data="@Series3Data"
160+
Name="Dotted Line"
161+
XField="@nameof(ModelData.X)"
162+
YField="@nameof(ModelData.Y)"
163+
DashType="@DashType.Dot">
164+
<ChartSeriesMarkers Visible="false" />
165+
</ChartSeries>
139166
140-
<ChartLegend Position="ChartLegendPosition.Right">
141-
</ChartLegend>
167+
</ChartSeriesItems>
142168
</TelerikChart>
143169
144170
@code {
145-
#region LinesData
146-
private List<object> firstColumnTypeData = new List<object>() { 10, 2, 5, 6 };
147-
private List<object> secondColumnTypeData = new List<object>() { 5, 8, 2, 7 };
171+
public class ModelData
172+
{
173+
public int X { get; set; }
174+
public int Y { get; set; }
175+
}
176+
public class BubbleData
177+
{
178+
public int X { get; set; }
179+
public int Y { get; set; }
180+
public int SizeField { get; set; }
181+
}
182+
183+
public List<ModelData> Series1Data = new List<ModelData>()
184+
{
185+
new ModelData() { X = 120, Y = 0 },
186+
new ModelData() { X = 120, Y = 100 },
187+
};
148188
149-
private List<object> firstLineTypeData = new List<object>() { 8, 8, 8, 6 };
150-
private List<object> secondLineTypeData = new List<object>() { 5, 8, 2, 7 };
189+
public List<ModelData> Series2Data = new List<ModelData>()
190+
{
191+
new ModelData() { X = 0, Y = 20 },
192+
new ModelData() { X = 140, Y = 20 },
193+
};
151194
152-
private string[] xColumnAxisItems = new string[] { "Q1", "Q2", "Q3", "Q4" };
153-
#endregion
195+
public List<ModelData> Series3Data = new List<ModelData>()
196+
{
197+
new ModelData() { X = 0, Y = 80 },
198+
new ModelData() { X = 140, Y = 80 },
199+
};
200+
201+
public List<BubbleData> SeriesBubbleData = new List<BubbleData>()
202+
{
203+
new BubbleData() { X = 40, Y = 40 , SizeField=1000},
204+
new BubbleData() { X = 66, Y = 77 , SizeField=500},
205+
new BubbleData() { X = 90, Y = 50 , SizeField=200},
206+
new BubbleData() { X = 120, Y = 70 , SizeField=350}
207+
};
208+
209+
public List<ModelData> SeriesScatterData = new List<ModelData>()
210+
{
211+
new ModelData() { X = 10, Y = 10 },
212+
new ModelData() { X = 17, Y = 50 },
213+
new ModelData() { X = 18, Y = 70 },
214+
new ModelData() { X = 35, Y = 90 },
215+
new ModelData() { X = 47, Y = 95 },
216+
new ModelData() { X = 100, Y = 100 }
217+
};
154218
}
155219
````
156220

157221
## See Also
158222

159223
* [Charts Plot Bands]({%slug chart-plot-bands%})
160-
* [Lines Chart](https://demos.telerik.com/blazor-ui/chart/line-chart)
224+
* [ScatterLine Chart](https://demos.telerik.com/blazor-ui/chart/scatter-line-chart)

knowledge-base/grid-filter-column-list.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ The example below includes two Grids - one for each `FilterMode`.
7272
<GridColumn Field="@nameof(Food.Name)" Title="Food" />
7373
<GridColumn Field="@nameof(Food.SpiceIds)" Title="Spices" Sortable="false">
7474
<Template>
75-
@{ var dataItem = (Food)context; }
75+
@{
76+
var dataItem = (Food)context;
77+
}
7678
<ul>
7779
@foreach (var spiceId in dataItem.SpiceIds)
7880
{
@@ -104,9 +106,11 @@ The example below includes two Grids - one for each `FilterMode`.
104106
Height="600px">
105107
<GridColumns>
106108
<GridColumn Field="@nameof(Food.Name)" Title="Food" />
107-
<GridColumn Field="@nameof(Food.SpiceIds)" Title="Spices" Sortable="false">
109+
<GridColumn Field="@nameof(Food.SpiceIds)" Title="Spices" Sortable="false" HeaderClass="@SpicesHeaderClass">
108110
<Template>
109-
@{ var dataItem = (Food)context; }
111+
@{
112+
var dataItem = (Food)context;
113+
}
110114
<ul>
111115
@foreach (var spiceId in dataItem.SpiceIds)
112116
{
@@ -133,9 +137,22 @@ The example below includes two Grids - one for each `FilterMode`.
133137
</GridColumns>
134138
</TelerikGrid>
135139
140+
<style>
141+
.active-filter .k-grid-header-menu {
142+
background-color: var(--kendo-color-primary);
143+
color: var(--kendo-color-on-primary);
144+
}
145+
146+
.active-filter .k-grid-header-menu:hover {
147+
background-color: var(--kendo-color-primary);
148+
}
149+
</style>
150+
136151
@code {
137152
private List<Food> GridData { get; set; } = new List<Food>();
138153
154+
private string SpicesHeaderClass { get; set; } = string.Empty;
155+
139156
private List<Spice> Spices { get; set; } = new List<Spice>() {
140157
new Spice() { Id = 1, Name = "Salt" },
141158
new Spice() { Id = 2, Name = "Pepper" },
@@ -165,6 +182,10 @@ The example below includes two Grids - one for each `FilterMode`.
165182
{
166183
filteredData.RemoveAll(x => !RowFilteredSpiceIds.All(y => x.SpiceIds.Contains(y)));
167184
}
185+
else
186+
{
187+
SpicesHeaderClass = string.Empty;
188+
}
168189
169190
var result = await filteredData.ToDataSourceResultAsync(args.Request);
170191
@@ -197,6 +218,9 @@ The example below includes two Grids - one for each `FilterMode`.
197218
{
198219
MenuFilteredSpiceIds = new List<int>();
199220
await context.ClearFilterAsync();
221+
222+
// Because the filtering occurs outside of the Grid, the active filter style requires manual clearing.
223+
SpicesHeaderClass = "";
200224
}
201225
202226
private async Task OnGridReadMenuFilter(GridReadEventArgs args)
@@ -206,6 +230,9 @@ The example below includes two Grids - one for each `FilterMode`.
206230
if (MenuFilteredSpiceIds.Any())
207231
{
208232
filteredData.RemoveAll(x => !MenuFilteredSpiceIds.All(y => x.SpiceIds.Contains(y)));
233+
234+
// Because the filtering occurs outside of the Grid, the active filter style requires manual applying.
235+
SpicesHeaderClass = "active-filter";
209236
}
210237
211238
var result = await filteredData.ToDataSourceResultAsync(args.Request);
@@ -228,11 +255,11 @@ The example below includes two Grids - one for each `FilterMode`.
228255
var spiceIdsForItem = Spices.OrderBy(x => rnd.Next()).Take(3).OrderBy(x => x.Name).Select(x => x.Id).ToList();
229256
230257
GridData.Add(new Food()
231-
{
232-
Id = i,
233-
Name = $"Food {i}",
234-
SpiceIds = spiceIdsForItem
235-
});
258+
{
259+
Id = i,
260+
Name = $"Food {i}",
261+
SpiceIds = spiceIdsForItem
262+
});
236263
}
237264
238265
Spices = Spices.OrderBy(x => x.Name).ToList();

0 commit comments

Comments
 (0)