-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b21deb6
commit c67e98d
Showing
9 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,3 +396,6 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
|
||
# MacOS | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# [⮪](../README.md) Setting Entry Images | ||
Once you've [setup](../../README.md#-setting-up) your [`DonutChartView`](../Reference/DonutChartView.md) there's a property called [`EntryIconTemplate`](../Reference/DonutChartView.md) that you can populate to render icons for each entry. This property expects a [`DataTemplate`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.datatemplate?view=net-maui-8.0) that creates a [`FileImageSource`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.fileimagesource?view=net-maui-8.0). | ||
|
||
## Static Image | ||
So if your MAUI project had an image file called `baseball.png`, to render every entry with that image you'd populate the property as follows: | ||
|
||
```xaml | ||
<donut:DonutChartView.EntryIconTemplate> | ||
<DataTemplate> | ||
<FileImageSource File="baseball.png" /> | ||
</DataTemplate> | ||
</donut:DonutChartView.EntryIconTemplate> | ||
``` | ||
|
||
Which might look something like this: | ||
|
||
<img src="../../Media/EntryImages-1.png" alt="Example Image #1" width="75%"/> | ||
<br/><br/> | ||
|
||
> [!NOTE] | ||
> If your images are rendering too large or too small, set the [`EntryImageScale`](../Reference/DonutChartView.md) on your [`DonutChartView`](../Reference/DonutChartView.md) accordingly. | ||
## Dynamic Image | ||
In most scenarios you're going to want to set each entry's image depending on a condition. To allow for this the [`EntryIconTemplate`](../Reference/DonutChartView.md) that you set is provided the original entry object as its binding context, meaning you can handle the image selection however you'd like. | ||
|
||
Say your [`EntriesSource`](../Reference/DonutChartView.md) entries are of type `TestResult`, you can setup your [`EntryIconTemplate`](../Reference/DonutChartView.md) with the `x:DataType` tag to allow for compiled bindings and then bind the image file on the [`FileImageSource`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.fileimagesource?view=net-maui-8.0). | ||
|
||
In the following example, we bind to a property called `Category` on the `TestResult` model which is an [`enum`](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum). Then we use a [binding value converter](https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/data-binding/converters?view=net-maui-8.0) to convert the `TestResult`'s `Category` to the image file we want to display. | ||
|
||
```xaml | ||
<donut:DonutChartView.EntryIconTemplate> | ||
<DataTemplate x:DataType="m:TestResult"> | ||
<FileImageSource File="{Binding Category, Converter={StaticResource ResultCategoryImageConverter}}" /> | ||
</DataTemplate> | ||
</donut:DonutChartView.EntryIconTemplate> | ||
``` | ||
|
||
Which might look something like this: | ||
|
||
<img src="../../Media/EntryImages-2.png" alt="Example Image #2" width="75%"/> | ||
<br/><br/> | ||
|
||
> [!NOTE] | ||
> If your images are rendering too large or too small, set the [`EntryImageScale`](../Reference/DonutChartView.md) on your [`DonutChartView`](../Reference/DonutChartView.md) accordingly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# [⮪](../README.md) Examples | ||
Want to see some code in action? Check the links below to help you get started. | ||
|
||
## Links | ||
- [Quick Setup](../../README.md#-setting-up) | ||
- [Setting Entry Images](EntryImages.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters