Skip to content

Commit e6f5dfb

Browse files
modified README.md
1 parent 1f4173a commit e6f5dfb

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

README.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# How-to-bind-the-Xamarin-Pie-Chart-Tooltip-to-Others-category-values
1+
# How to bind the Xamarin.Forms pie chart tooltip to “Otherscategory values
22

33
We always like to group smaller pie chart values into the category "Others" to increase chart readability. But we also think about ways to show those grouped values in UI.
44

@@ -11,8 +11,7 @@ The example of the code below shows “How to calculate and display the average
1111

1212
### Step 1: Declaration IValueConverter to calculate average values.
1313

14-
{% tabs %}
15-
14+
```
1615
public class ChartAvgValueConverter : IValueConverter
1716
{
1817
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -43,17 +42,14 @@ public class ChartAvgValueConverter : IValueConverter
4342
return null;
4443
}
4544
46-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
47-
{
48-
return value;
49-
}
5045
}
46+
```
5147

5248
{% endhighlight %}
5349

5450
### Step 2: DataTemplate declarations.
5551

56-
{% tabs %}
52+
```
5753
<ContentView.Resources>
5854
<local:ChartAvgValueConverter x:Key="sumOfValuesConverter"/>
5955
<DataTemplate x:Key="TooltipTemplate">
@@ -63,11 +59,11 @@ public class ChartAvgValueConverter : IValueConverter
6359
</StackLayout>
6460
</DataTemplate>
6561
</ContentView.Resources>
66-
{% endhighlight %}
62+
```
6763

6864
### Step 3: DataTemplate defined in the Series Tooltip Template.
6965

70-
{% tabs %}
66+
```
7167
<chart:SfChart BackgroundColor="Transparent">
7268
. . .
7369
<chart:SfChart.Series>
@@ -87,15 +83,15 @@ public class ChartAvgValueConverter : IValueConverter
8783
<chart:ChartTooltipBehavior BackgroundColor="LightBlue
8884
</chart:SfChart.ChartBehaviors>
8985
</chart:SfChart>
90-
{% endhighlight %}
86+
```
9187

9288
## How to bind the Xamarin.Forms Pie Chart grouped data collection to the Tooltip
9389

9490
The example of the code below shows “How to display the values which present inside the group ‘Others’?”
9591

9692
Step 1: Declaration IValueConverter to generate BindableLayout ItemsSource
9793

98-
{% tabs %}
94+
```
9995
public class ChartValueConverter : IValueConverter
10096
{
10197
//Which returns ItemsSource for bindable layout.
@@ -118,17 +114,12 @@ public class ChartValueConverter : IValueConverter
118114
119115
return value;
120116
}
121-
122-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
123-
{
124-
return value;
125-
}
126117
}
127-
{% endhighlight %}
118+
```
128119

129120
Step 2: DataTemplate declarations with any of the BindableLayout.
130121

131-
{% tabs %}
122+
```
132123
<ContentView.Resources>
133124
<local:ChartValueConverter x:Key="itemsSourceConverter"/>
134125
<DataTemplate x:Key="TooltipTemplate">
@@ -144,11 +135,11 @@ Step 2: DataTemplate declarations with any of the BindableLayout.
144135
</StackLayout>
145136
</DataTemplate>
146137
</ContentView.Resources>
147-
{% endhighlight %}
138+
```
148139

149140
Step 3: DataTemplate defined in the Series Tooltip Template.
150141

151-
{% tabs %}
142+
```
152143
<chart:SfChart BackgroundColor="Transparent">
153144
. . .
154145
<chart:SfChart.Series>
@@ -165,4 +156,4 @@ Step 3: DataTemplate defined in the Series Tooltip Template.
165156
<chart:ChartTooltipBehavior BackgroundColor="LightBlue
166157
</chart:SfChart.ChartBehaviors>
167158
</chart:SfChart>
168-
{% endhighlight %}
159+
```

0 commit comments

Comments
 (0)