I've run into an issue with SfChart. After a call to
GetStream(), certain aspects of the chart UI become unresponsive. For
instance, I am no longer able to update the chart's title, and any
updates to the chart's data model cause the axis markings to disappear.
Here's
some sample code that demonstrates the problem. If you click the "Test"
button, you will see that the chart's title becomes stuck at "Before
Stream" and is never updated to "After Stream". If, however, you comment
out the using statement that makes the call to GetStream(), the title
updates to "After Stream" as expected.
public class ChartStreamPage
: ContentPage
{
public ChartStreamPage()
{
SfChart chart = new SfChart();
chart.HorizontalOptions = LayoutOptions.FillAndExpand;
chart.VerticalOptions = LayoutOptions.FillAndExpand;
chart.Title.Text = "Start";
LogarithmicAxis primaryAxis = new LogarithmicAxis();
NumericalAxis secondaryAxis = new NumericalAxis();
chart.PrimaryAxis = primaryAxis;
chart.SecondaryAxis = secondaryAxis;
Button testBtn = new Button();
testBtn.Text = "Test";
testBtn.Clicked += (sender, e) =>
{
chart.Title.Text = "Before Stream";
// comment / uncomment this statement to see change in behavior
using (System.IO.Stream stream = chart.GetStream())
{
;
}
// unless using statement is commented out, this change is not reflected in the UI
chart.Title.Text = "After Stream";
};
StackLayout layout = new StackLayout();
layout.Children.Add(chart);
layout.Children.Add(testBtn);
Content = layout;
}
}