BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hi guys! Im trying to implement dynamic ranges to the control. However, when I run the app, it's not displaying the ranges.
This is my xlml code:
<gauge:SfLinearGauge
Grid.Row="0"
Grid.Column="1"
x:Name="lineargauge"
Orientation="OrientationHorizontal"
VerticalOptions="StartAndExpand">
<gauge:SfLinearGauge.Scales>
<gauge:LinearScale
x:Name="linearscale"
ScaleBarSize="15"
ScaleBarColor="{DynamicResource BoxViewIconos}"
MinorTicksPerInterval="1"
LabelColor="{DynamicResource PrimaryTextColor}"
ShowLabels="true"
LabelFontSize="10"
Interval="25"
MinimumValue="0"
MaximumValue="100"
CornerRadiusType="Both"
CornerRadius="10">
<gauge:LinearScale.MajorTickSettings>
<gauge:LinearTickSettings
Thickness="1"
Color="{DynamicResource PrimaryTextColor}"
Length="8"/>
</gauge:LinearScale.MajorTickSettings>
<gauge:LinearScale.MinorTickSettings>
<gauge:LinearTickSettings
Thickness="1"
Color="{DynamicResource PrimaryTextColor}"
Length="4"/>
</gauge:LinearScale.MinorTickSettings>
<gauge:LinearScale.Pointers>
<gauge:BarPointer
x:Name="BarPointer"
EnableAnimation = "true"
AnimationDuration="2"
CornerRadiusType="Both"
CornerRadius="20"/>
</gauge:LinearScale.Pointers>
<gauge:LinearScale.Ranges/>
</gauge:LinearScale>
</gauge:SfLinearGauge.Scales>
</gauge:SfLinearGauge>
This is my code behind:
RangosRootObject res = JsonConvert.DeserializeObject<RangosRootObject>(response);
double valorInicial = 0;
double valorFinal = 0;
var rangos = new List<LinearRange>();
foreach (var rango in res.data.Rangos)
{
valorFinal = rango.FRONTERA;
if (valorInicial == valorFinal)
valorFinal = 100;
rangos.Add(new LinearRange
{
StartValue = valorInicial,
EndValue = valorFinal,
Color = Color.FromHex(rango.COLORHEXA),
StartWidth = 15,
EndWidth = 15
});
valorInicial = rango.FRONTERA;
}
linearscale.Ranges = rangos;
I have attached a sample file with the json file used to recover the ranges data.
Thanks!
Hi Andres,
Regarding “Cannot add ranges to linear gauge dynamically”:
As per the current implementation, in the Xamarin Forms SfLinearGauge control, the Ranges property is of type List<LinearRange>, which does not support automatic UI updates when items are added or removed. Consequently, adding a new range to the Ranges property at runtime does not trigger a UI update. This is the expected behavior.
As an alternative, we recommend using our .NET MAUI SfLinearGauge control, which includes similar functionalities and supports dynamically adding new ranges at runtime.
Please refer to the following UG link to know how to get started with the .NET MAUI SfLinearGauge control: https://help.syncfusion.com/maui/linear-gauge/getting-started.
We hope that this helps you. Please let us know if you need further assistance.
Regards,
Vishal O.
Hi Vishal O. Thanks for the reply.
Running the project on Android, it does show the ranges as expected, as you can see on the attached image. Unfortunately, Maui is not an option right now for me, since it would mean to transfer the whole project.
The problem is specific to iOS.
Again, thanks for your help.
Andres.
Hi Andres,
Based on the details provided, we have checked the reported query using a simple sample created from the provided code snippet. However, we were unable to replicate the reported scenario on our end. The ranges were displayed correctly on the iOS platform as expected. We have shared the tested sample along the tested output screenshot below for your reference.
Please check the provided sample and let us know whether you are still encountering the same issue? If the problem persists, we kindly request you to modify (or) update our sample to reproduce the issue and revert to us with an issue reproducible runnable sample, a video (or screenshot) demonstrating the issue being replicated, etc., Providing this additional information will enable us to check the scenario more effectively and provide you a better solution. We appreciate your understanding on this.
Regards,
Vishal O.
Hi Vishal! Thanks for the sample. I have made some modifications to your code, in order to replicate the problem on iOS.
I noticed that when I call the method "ObtenerRangos" from OnAppearig, data is loaded from my web service but it isn't shown on the control. The same happens if I add the ranges manually.
Thanks for your help.
Andres.
Hi Andres,
We have checked and we are able to replicate the reported scenario “Cannot add ranges to linear gauge dynamically on iOS platform” on the Xamarin.Forms SfLinearGauge control, from our end. We have logged issue report for the same. We will fix this issue and will include the fix in our upcoming weekly NuGet release update, which is expected to roll out on December 17, 2024. We appreciate your patience until then.
You can track the status of this report through the following feedback link.
Feedback link: https://www.syncfusion.com/feedback/63467/unable-to-add-ranges-to-linear-gauge-dynamically-on-ios-platform.
Note: The provided feedback link is private, and you need to log in to view this feedback.
Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
Regards,
Vishal O.
Hi Andres,
We have fixed the reported scenario “Cannot add ranges to linear gauge dynamically on iOS platform” in the Xamarin.Forms SfLinearGauge control from our end and included the fix in the latest weekly NuGet release update version 28.1.35, which is available for download in nuget.org.
Root-cause: The Ranges were not drawn when adding dynamically on iOS platform.
We thank you for your support and appreciate your patience in waiting for this update. Please feel free to reach out to us if you would require any further assistance.
Regards,
Vishal O.
Hi Vishal O. Thanks for the update. I can confirm that it works as expected. Thanks a lot for your help!
Andres
Hi Andres,
You are welcome.
We are glad to know that the reported problem has been resolved. We are
marking this thread as solved. Please let us know if you require any further
assistance on this. We will be happy to assist you.
Regards,
Preethi R