Skip to content

Commit 7345cc4

Browse files
committed
cleared null exception
1 parent a47db97 commit 7345cc4

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

maui/samples/Gallery/SampleList/CartesianChartSamplesList.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
</CardLayout>
5858
</SubCategory>
5959

60-
<Sample Title="Fast Scatter" StatusTag="New" SampleName="FastScatterChart" SearchTags="scatter, scatter chart, scatter plot, fast scatter, fast scatter chart, fast scatter plot, high performance chart"/>
61-
6260
<SubCategory Title="Spline">
6361
<CardLayout>
6462
<Sample Title="Default spline chart" SampleName="SplineChart" Description="This sample demonstrates the default spline chart. The marker, tooltip, and legend are enabled in the model. Tap the data point to view information about that data point in a tooltip." SearchTags="spline"/>

maui/src/Charts/Series/BoxAndWhiskerSeries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ internal override void GeneratePropertyPoints(string[] yPaths, IList<double>[] y
743743
}
744744
}
745745

746-
internal override void SetIndividualPoint(int index, object obj, bool replace)
746+
internal override void SetIndividualPoint(object obj, int index, bool replace)
747747
{
748748
if (YDataCollection != null && YPaths != null && ItemsSource != null)
749749
{

maui/src/Charts/Series/CartesianSeries.cs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,12 +1065,9 @@ internal override void OnDataSourceChanged(object oldValue, object newValue)
10651065
InvalidateSideBySideSeries();
10661066
foreach (var item in EmptyPointIndexes)
10671067
{
1068-
if (item != null)
1069-
1070-
{
1071-
item.Clear();
1072-
}
1068+
item?.Clear();
10731069
}
1070+
10741071
base.OnDataSourceChanged(oldValue, newValue);
10751072
}
10761073

@@ -1080,31 +1077,25 @@ internal override void OnDataSource_CollectionChanged(object? sender, NotifyColl
10801077
base.OnDataSource_CollectionChanged(sender, e);
10811078
}
10821079

1083-
internal override void AddDataPoint(int index, object data, NotifyCollectionChangedEventArgs e)
1080+
internal override void AddDataPoint(object data, int index, NotifyCollectionChangedEventArgs e)
10841081
{
10851082
ResetEmptyPointIndexes();
10861083
foreach (var item in EmptyPointIndexes)
10871084
{
1088-
if (item != null)
1089-
1090-
{
1091-
item.Clear();
1092-
}
1085+
item?.Clear();
10931086
}
1094-
base.AddDataPoint(index, data, e);
1087+
1088+
base.AddDataPoint(data, index, e);
10951089
}
10961090

10971091
internal override void RemoveData(int index, NotifyCollectionChangedEventArgs e)
10981092
{
10991093
ResetEmptyPointIndexes();
11001094
foreach (var item in EmptyPointIndexes)
11011095
{
1102-
if (item != null)
1103-
1104-
{
1105-
item.Clear();
1106-
}
1096+
item?.Clear();
11071097
}
1098+
11081099
base.RemoveData(index, e);
11091100
}
11101101

maui/src/Charts/Series/ChartSeriesPartial.cs

Lines changed: 4 additions & 4 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(int index, object data, NotifyCollectionChangedEventArgs e)
85+
internal virtual void AddDataPoint(object data, int index, NotifyCollectionChangedEventArgs e)
8686
#pragma warning restore IDE0060 // Remove unused parameter
8787
{
88-
SetIndividualPoint(index, data, false);
88+
SetIndividualPoint(data, index, false);
8989
}
9090

9191
internal virtual void LegendItemToggled(LegendItem chartLegendItem)
@@ -116,7 +116,7 @@ internal virtual void GenerateDataPoints()
116116
internal virtual void OnDataSource_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
117117
{
118118
IsDataPointAddedDynamically = false;
119-
e.ApplyCollectionChanges((obj, index, canInsert) => AddDataPoint(index, obj, e), (obj, index) => RemoveData(index, e), ResetDataPoint);
119+
e.ApplyCollectionChanges((obj, index, canInsert) => AddDataPoint(obj, index, e), (obj, index) => RemoveData(index, e), ResetDataPoint);
120120

121121
if (e.Action == NotifyCollectionChangedAction.Add && EnableAnimation && AnimationDuration > 0)
122122
{
@@ -219,7 +219,7 @@ internal void InvalidateGroupValues()
219219
//TODO:Need to remove the replace parameter from this method,
220220
//because new notify collectionChanged event first remove
221221
//the data and then insert the data. So no need replace parameter here after.
222-
internal virtual void SetIndividualPoint(int index, object obj, bool replace)
222+
internal virtual void SetIndividualPoint(object obj, int index, bool replace)
223223
{
224224
if (SeriesYValues != null && YPaths != null && ItemsSource != null)
225225
{

maui/src/Charts/Series/PieSeries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,9 @@ internal override void RemoveData(int index, NotifyCollectionChangedEventArgs e)
599599
CalculateGroupToYValues();
600600
}
601601

602-
internal override void SetIndividualPoint(int index, object obj, bool replace)
602+
internal override void SetIndividualPoint(object obj, int index, bool replace)
603603
{
604-
base.SetIndividualPoint(index, obj, replace);
604+
base.SetIndividualPoint(obj, index, replace);
605605

606606
CalculateGroupToYValues();
607607
}

maui/src/Charts/Series/RangeColumnSeries.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ internal override void GenerateTrackballPointInfo(List<object> nearestDataPoints
417417
double yValue = yValues[index];
418418
double yValue1 = yValues1[index];
419419
string label = string.Format("{0} : {1:#.##}\n{2} : {3:#.##}", SfCartesianChartResources.High, yValue, SfCartesianChartResources.Low, yValue1);
420+
if (yValue == 0 || yValue1 == 0)
421+
{
422+
label = string.Format("{0} : {1:0.##}\n{2} : {3:0.##}", SfCartesianChartResources.High, yValue, SfCartesianChartResources.Low, yValue1);
423+
}
420424

421425
if (IsSideBySide)
422426
{

maui/src/Charts/Series/SplineRangeAreaSeries.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ internal override void GenerateTrackballPointInfo(List<object> nearestDataPoints
491491
double highValue = highValues[index];
492492
double lowValue = lowValues[index];
493493
string label = string.Format("{0} : {1:#.##}\n{2} : {3:#.##}", SfCartesianChartResources.High, highValue, SfCartesianChartResources.Low, lowValue);
494+
if (highValue == 0 || lowValue == 0)
495+
{
496+
label = string.Format("{0} : {1:0.##}\n{2} : {3:0.##}", SfCartesianChartResources.High, highValue, SfCartesianChartResources.Low, lowValue);
497+
}
498+
494499
var xPoint = TransformToVisibleX(xValue, topValue);
495500
var yPoint = TransformToVisibleY(xValue, topValue);
496501

0 commit comments

Comments
 (0)