Skip to content

Commit ee687ad

Browse files
Merge pull request #7226 from syncfusion-content/996523-StriplineTooltipUG
996523: Provided UG documentation support for the stripline tooltip feature.
2 parents a86476c + 4feead0 commit ee687ad

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed
31.6 KB
Loading
33.8 KB
Loading

blazor/chart/strip-line.md

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,192 @@ To create a stripline in a specific region with respect to a segment (segmented
248248
```
249249
{% previewsample "https://blazorplayground.syncfusion.com/embed/rNLqMVhHrJGZtGLh?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Blazor Chart With Segmented Stripline](../chart/images/strip-line/blazor-chart-segmented-stripline.png)" %}
250250

251+
## Stripline tooltip
252+
253+
Stripline tooltips provide additional contextual information on interaction with striplines in the chart. To display a tooltip on a stripline, add the **ChartStriplineTooltip** component inside the desired **ChartStripline** and set the **Enable** property to **true**. It is particularly useful for explaining the significance of specific ranges or thresholds marked by striplines.
254+
255+
### Default stripline tooltip code example:
256+
257+
Below is the simplest way to enable a stripline tooltip using default settings. The tooltip will display on interaction with the stripline.
258+
259+
```cshtml
260+
261+
@using Syncfusion.Blazor.Charts
262+
263+
@* Initialize the Chart to display vehicle traffic by time using a Spline series. *@
264+
<SfChart Title="Vehicle Traffic by Time">
265+
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime"
266+
IntervalType="IntervalType.Hours"
267+
LabelFormat="h tt">
268+
<ChartStriplines>
269+
270+
@* Stripline: visual band marking Rush Hour on the X axis *@
271+
<ChartStripline Start="new DateTime(2024, 01, 01, 07, 00, 00)"
272+
End="new DateTime(2024, 01, 01, 09, 00, 00)"
273+
Text="Rush Hour"
274+
Color="#FFED4A"
275+
Visible="true">
276+
277+
@* Stripline Tooltip: shows 'Rush Hour' with band hover/tap *@
278+
<ChartStriplineTooltip Enable="true"></ChartStriplineTooltip>
279+
</ChartStripline>
280+
</ChartStriplines>
281+
</ChartPrimaryXAxis>
282+
283+
<ChartPrimaryYAxis Minimum="0" Maximum="1400" Interval="200" Title="Number of vehicles">
284+
</ChartPrimaryYAxis>
285+
286+
<ChartSeriesCollection>
287+
<ChartSeries Type="ChartSeriesType.Spline"
288+
DataSource="@Traffic"
289+
XName="Time"
290+
YName="Vehicles"
291+
Width="2"
292+
Fill="#F43F5E">
293+
</ChartSeries>
294+
</ChartSeriesCollection>
295+
</SfChart>
296+
297+
@code {
298+
public class TrafficPoint
299+
{
300+
public DateTime Time { get; set; }
301+
public double Vehicles { get; set; }
302+
}
303+
304+
public List<TrafficPoint> Traffic = new ()
305+
{
306+
new TrafficPoint { Time = new DateTime(2024, 01, 01, 06, 00, 00), Vehicles = 380 },
307+
new TrafficPoint { Time = new DateTime(2024, 01, 01, 07, 00, 00), Vehicles = 820 },
308+
new TrafficPoint { Time = new DateTime(2024, 01, 01, 08, 00, 00), Vehicles = 1200 },
309+
new TrafficPoint { Time = new DateTime(2024, 01, 01, 09, 00, 00), Vehicles = 980 },
310+
new TrafficPoint { Time = new DateTime(2024, 01, 01, 10, 00, 00), Vehicles = 650 },
311+
new TrafficPoint { Time = new DateTime(2024, 01, 01, 11, 00, 00), Vehicles = 520 }
312+
};
313+
}
314+
315+
```
316+
317+
![Blazor Chart with Default Stripline Tooltip](images/strip-line/blazor-chart-stripline-tooltip-default.png)
318+
319+
### Tooltip customization properties
320+
321+
The stripline tooltip offers comprehensive customization options through the following properties:
322+
323+
- **Enable** - A boolean property that enables or disables the stripline tooltip. Default value is **false**.
324+
325+
- **Header** - Defines the title text displayed at the top of the tooltip.
326+
327+
- **Content** - Allows you to specify custom content for the tooltip body using a format string. The format supports token placeholders that are replaced with corresponding values at runtime. Supported tokens:
328+
- **${stripline.text}** – The stripline label.
329+
- **${stripline.start}** – The stripline start value.
330+
- **${stripline.end}** – The stripline end value.
331+
- **${axis.name}** – The axis name.
332+
- **${stripline.segmentStart}** – The stripline segment start value (if applicable).
333+
- **${stripline.segmentEnd}** – The stripline segment end value (if applicable).
334+
- **${stripline.segmentAxisName}** – The stripline segment axis name (if applicable).
335+
- **${stripline.size}** – The stripline size (if applicable).
336+
337+
- **Fill** - Sets the background color of the tooltip. Accepts any valid CSS color value (hex, rgb, rgba, named colors).
338+
339+
- **Opacity** - Controls the transparency level of the tooltip background. Accepts numeric values between 0 (completely transparent) and 1 (completely opaque). The default value is 0.75.
340+
341+
- **ShowHeaderLine** - A boolean property that controls the visibility of the horizontal separator line between the tooltip header and content. Set to **true** to display the line or **false** to hide it.
342+
343+
The **ChartStriplineTooltipTextStyle** component allows you to customize the appearance of text within the tooltip:
344+
345+
- **Size** - Specifies the font size of the tooltip text. Accepts pixel values (e.g., "12px").
346+
347+
- **Color** - Defines the text color. Accepts any valid CSS color value.
348+
349+
- **FontFamily** - Sets the font family for the tooltip text. Accepts standard CSS font family values (e.g., "Arial", "Segoe UI", "Roboto").
350+
351+
- **FontWeight** - Controls the thickness of the text.
352+
353+
The **ChartStriplineTooltipBorder** component enables you to add and customize borders around the tooltip:
354+
355+
- **Width** - Specifies the thickness of the tooltip border in pixels. Accepts numeric values. Default value is **0**.
356+
357+
- **Color** - Defines the color of the tooltip border. Accepts any valid CSS color value.
358+
359+
### Customized stripline tooltip code example:
360+
361+
```cshtml
362+
363+
@using Syncfusion.Blazor.Charts
364+
365+
@* Initialize the Chart to display department revenue by quarter using Column and Spline series. *@
366+
<SfChart Title="Department Revenue by Quarter">
367+
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category">
368+
<ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
369+
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
370+
</ChartPrimaryXAxis>
371+
372+
<ChartPrimaryYAxis Minimum="65" Maximum="110" Interval="5" LabelFormat="${value}k" RangePadding="Syncfusion.Blazor.Charts.ChartRangePadding.None">
373+
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
374+
<ChartStriplines>
375+
376+
@* Stripline: Highlights the upper revenue target range from 95k to 110k with text style and border customization. *@
377+
<ChartStripline Start="95" End="110" Color="#FFF59E" HorizontalAlignment="Anchor.Middle" Visible="true">
378+
<ChartStriplineTextStyle Size="12px" Color="#0b3a66" FontWeight="600"></ChartStriplineTextStyle>
379+
<ChartStriplineBorder Width="0"></ChartStriplineBorder>
380+
381+
@* Stripline Tooltip: providing interactive context with customizatioon for the target bands over hover/tap *@
382+
<ChartStriplineTooltip Enable="true"
383+
Header="Target"
384+
Content="Range: ${stripline.start} - ${stripline.end}<br/>Axis: ${axis.name}"
385+
Fill="#F43F5E"
386+
Opacity="0.95"
387+
ShowHeaderLine="true">
388+
<ChartStriplineTooltipTextStyle Size="14px" Color="#FFFFFF" FontWeight="600" FontFamily="Segoe UI"></ChartStriplineTooltipTextStyle>
389+
<ChartStriplineTooltipBorder Width="2" Color="#1F2937"></ChartStriplineTooltipBorder>
390+
</ChartStriplineTooltip>
391+
</ChartStripline>
392+
</ChartStriplines>
393+
</ChartPrimaryYAxis>
394+
395+
<ChartSeriesCollection>
396+
<ChartSeries Name="Sales" Type="ChartSeriesType.Column" DataSource="@SalesData" XName="Quarter" YName="Revenue" ColumnSpacing="0.2" Width="2" Fill="#FB923C">
397+
<ChartMarker Visible="false"></ChartMarker>
398+
</ChartSeries>
399+
<ChartSeries Name="Support" Type="ChartSeriesType.Spline" DataSource="@SupportData" XName="Quarter" YName="Revenue" Width="2" Fill="#22C55E">
400+
<ChartMarker Visible="true">
401+
<ChartDataLabel Visible="true"></ChartDataLabel>
402+
</ChartMarker>
403+
</ChartSeries>
404+
</ChartSeriesCollection>
405+
406+
<ChartLegendSettings Visible="true" EnableHighlight="true"></ChartLegendSettings>
407+
</SfChart>
408+
409+
@code {
410+
public class RevenuePoint
411+
{
412+
public string Quarter { get; set; }
413+
public double Revenue { get; set; }
414+
}
415+
416+
public List<RevenuePoint> SalesData = new ()
417+
{
418+
new RevenuePoint { Quarter = "Q1", Revenue = 78 },
419+
new RevenuePoint { Quarter = "Q2", Revenue = 88 },
420+
new RevenuePoint { Quarter = "Q3", Revenue = 99 },
421+
new RevenuePoint { Quarter = "Q4", Revenue = 92 }
422+
};
423+
424+
public List<RevenuePoint> SupportData = new ()
425+
{
426+
new RevenuePoint { Quarter = "Q1", Revenue = 70 },
427+
new RevenuePoint { Quarter = "Q2", Revenue = 83 },
428+
new RevenuePoint { Quarter = "Q3", Revenue = 90 },
429+
new RevenuePoint { Quarter = "Q4", Revenue = 85 }
430+
};
431+
}
432+
433+
```
434+
435+
![Blazor Chart with Customized Stripline Tooltip](images/strip-line/blazor-chart-stripline-tooltip-customized.png)
436+
251437
N> Refer to our [Blazor Charts](https://www.syncfusion.com/blazor-components/blazor-charts) feature tour page for its groundbreaking feature representations and also explore our [Blazor Chart Example](https://blazor.syncfusion.com/demos/chart/line?theme=bootstrap5) to know various chart types and how to represent time-dependent data, showing trends at equal intervals.
252438

253439
## See also

0 commit comments

Comments
 (0)