Skip to content

Commit 77c9aeb

Browse files
committed
updated code for dynamic empty point values
1 parent 45b7269 commit 77c9aeb

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

maui/src/Charts/DataLabel/ChartDataLabelSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ internal string GetLabelContent(double value)
360360
}
361361
else
362362
{
363-
labelContent = value.ToString("#.##");
363+
labelContent = value == 0 ? value.ToString("0.##") : value.ToString("#.##");
364364
}
365365

366366
return labelContent;

maui/src/Charts/Series/CartesianSeries.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,15 @@ internal override void OnDataSourceChanged(object oldValue, object newValue)
10631063
{
10641064
ResetAutoScroll();
10651065
InvalidateSideBySideSeries();
1066-
RequiredEmptyPointReset = true;
1067-
base.OnDataSourceChanged(oldValue, newValue);
1066+
foreach (var item in EmptyPointIndexes)
1067+
{
1068+
if (item != null)
1069+
1070+
{
1071+
item.Clear();
1072+
}
1073+
}
1074+
base.OnDataSourceChanged(oldValue, newValue);
10681075
}
10691076

10701077
internal override void OnDataSource_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
@@ -1073,16 +1080,32 @@ internal override void OnDataSource_CollectionChanged(object? sender, NotifyColl
10731080
base.OnDataSource_CollectionChanged(sender, e);
10741081
}
10751082

1076-
internal override void AddDataPoint(object data, int index, NotifyCollectionChangedEventArgs e)
1083+
internal override void AddDataPoint(int index, object data, NotifyCollectionChangedEventArgs e)
10771084
{
1078-
RequiredEmptyPointReset = true;
1079-
base.AddDataPoint(data, index, e);
1085+
ResetEmptyPointIndexes();
1086+
foreach (var item in EmptyPointIndexes)
1087+
{
1088+
if (item != null)
1089+
1090+
{
1091+
item.Clear();
1092+
}
1093+
}
1094+
base.AddDataPoint(index, data, e);
10801095
}
10811096

10821097
internal override void RemoveData(int index, NotifyCollectionChangedEventArgs e)
10831098
{
1084-
RequiredEmptyPointReset = true;
1085-
base.RemoveData(index, e);
1099+
ResetEmptyPointIndexes();
1100+
foreach (var item in EmptyPointIndexes)
1101+
{
1102+
if (item != null)
1103+
1104+
{
1105+
item.Clear();
1106+
}
1107+
}
1108+
base.RemoveData(index, e);
10861109
}
10871110

10881111
internal override void OnBindingPathChanged()

maui/src/Charts/Series/ChartSeriesPartial.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ internal ChartValueType XValueType
8282
#region Internal Methods
8383

8484
#pragma warning disable IDE0060 // Remove unused parameter
85-
internal virtual void AddDataPoint(object data, int index, NotifyCollectionChangedEventArgs e)
85+
internal virtual void AddDataPoint(int index, object data, NotifyCollectionChangedEventArgs e)
8686
#pragma warning restore IDE0060 // Remove unused parameter
8787
{
88-
SetIndividualPoint(data, index, false);
88+
SetIndividualPoint(index, data, false);
8989
}
9090

9191
internal virtual void LegendItemToggled(LegendItem chartLegendItem)

maui/src/Charts/Styles/EmptyPointSettings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
///
1212
/// <para> To customize empty points, create an instance of <see cref="EmptyPointSettings"/>, configure it as needed, and then add it to the series.</para>
1313
///
14-
/// <para> EmptyPointSettings is not supported for all area-related series, as well as for FastChart.</para>
14+
/// <para> EmptyPointSettings is not supported for all area-related series, as well as for FastChart and ErrorBarSeries.</para>
1515
/// # [MainPage.xaml](#tab/tabid-1)
1616
/// <code><![CDATA[
1717
/// <chart:SfCartesianChart>
@@ -58,7 +58,7 @@
5858
/// series.EmptyPointMode = EmptyPointMode.Zero;
5959
/// series.EmptyPointSettings = new EmptyPointSettings();
6060
/// series.EmptyPointSettings.Fill = Colors.Orange;
61-
/// series.MarEmptyPointSettingskerSettings.Stroke = Colors.Red;
61+
/// series.EmptyPointSettings.Stroke = Colors.Red;
6262
/// series.EmptyPointSettings.StrokeWidth = 3;
6363
/// chart.Series.Add(series);
6464
/// ]]>
@@ -187,7 +187,7 @@ public Brush Fill
187187
/// EmptyPointMode = EmptyPointMode.Average,
188188
/// };
189189
/// series.EmptyPointSettings = new EmptyPointSettings();
190-
/// series.MarEmptyPointSettingskerSettings.Stroke = Colors.Red;
190+
/// series.EmptyPointSettings.Stroke = Colors.Red;
191191
/// series.EmptyPointSettings.StrokeWidth = 3;
192192
/// chart.Series.Add(series);
193193
///

0 commit comments

Comments
 (0)