Closed Chico741 closed 7 years ago
@Chico741 I'm still looking at #11 , but they might be related as both only happens when you inherit from those classes.
Could you provide the code for this crash?
Thanks very much for your effort, please find the code below.
public class CustomBarChartView : BarChartView
{
public CustomBarChartView()
{
CustomBarChartDataSet providedDataSet = new CustomBarChartDataSet(new List<BarChartDataEntry> { new BarChartDataEntry(0, 89) }.ToArray(), "Provided");
providedDataSet.TintColor = ColorsHelperIOS.Blue;
CustomBarChartDataSet dummyDataSet = new CustomBarChartDataSet(new List<BarChartDataEntry> { new BarChartDataEntry(1, 10) }.ToArray(), "Dummy");
dummyDataSet.TintColor = UIColor.Clear;
CustomBarChartDataSet soldDataSet = new CustomBarChartDataSet(new List<BarChartDataEntry> { new BarChartDataEntry(2, 23) }.ToArray(), "Sold");
soldDataSet.TintColor = ColorsHelperIOS.Green;
BarChartData barData = new BarChartData(new List<BarChartDataSet> { providedDataSet, dummyDataSet, soldDataSet }.ToArray());
Data = barData;
HighlightPerTapEnabled = false;
Legend.Enabled = false;
DescriptionText = "";
LeftAxis.Enabled = false;
RightAxis.Enabled = false;
XAxis.Enabled = false;
DoubleTapToZoomEnabled = false;
PinchZoomEnabled = false;
UserInteractionEnabled = false;
nfloat sideOffset = 55;
SetViewPortOffsetsWithLeft(sideOffset, 20, sideOffset, 0);
}
}
public class CustomBarChartDataSet : BarChartDataSet
{
private UIColor _tintColor;
public UIColor TintColor {
get {
return _tintColor;
}
set {
_tintColor = value;
ValueTextColor = _tintColor;
BarBorderColor = _tintColor;
}
}
public CustomBarChartDataSet(BarChartDataEntry[] values, string label) : base(values, label)
{
ValueFormatter = new ValueFormatter();
ValueFont = FontsHelperIOS.SemiBold(17);
BarBorderWidth = 1.5f;
HighlightEnabled = false;
SetColor(UIColor.Clear);
}
}
public class ValueFormatter : InterfaceChartValueFormatter
{
public override string Entry(double value, ChartDataEntry entry, nint dataSetIndex, ChartViewPortHandler viewPortHandler)
{
return string.Format(LocalizationHelper.GetLocalizedString("community_value_format"), value);
}
}
@Flash3001 do you have any news regarding this issues?
@Chico741 I wasn't able to figure out yet what is causing this crash on device when any of those classes (BarChartView or ChartMarkerImage) are inherited.
In both cases you aren't changing those classes behavior, only setting public properties, you can use the default BarChartView and set the values outside the constructor.
In the case for #11 the image doesn't change based on the entry, so you can set it on the public property on the basic ChartMarkerImage.
Please, tell me if changing this design will work for you. Meanwhile I'll keep trying to find the root cause for the problem.
@Flash3001 you are right without subclassing everything is working fine. thanks for your help!
Same issue, but i need to inherit ChartMarkerView
I implemented a BarChartView which is crashing just on device. In my case on an iPhone6 with iOS 10.1. On simulator everything is running fine.
Could be the same issue like #11 ?