Giter VIP home page Giter VIP logo

Comments (7)

Flash3001 avatar Flash3001 commented on August 22, 2024

@kevinlcfei Are you still using version 2.2.4.1 or did you change to 2.2.5?

There were some property bindings done wrong in 2.2.4. I redid everything for 2.2.5.

Can you provide a log? If you can't catch the exception, it will be shown in the device logs.

from ioscharts.xamarin.

kevinlcfei avatar kevinlcfei commented on August 22, 2024

@Flash3001

Yes. updated via XPM to the latest version.
Using 2.2.5.1ver.

Tried catch exception in the sample code provided in XS - it failed to jump in.
Attached file for the log file for your reference.
crash log.txt

from ioscharts.xamarin.

Flash3001 avatar Flash3001 commented on August 22, 2024

@kevinlcfei What's the value for pieChartModel.dataSetLegend.Length?

PieChartView only supports one DataSet.

I've been running some tests today and it crashes only when it uses more than one PieChartDataSet in PieChartData.

Tell me if it is the same for your. If it isn't please provide a complete sample so I can give it a try too.

from ioscharts.xamarin.

kevinlcfei avatar kevinlcfei commented on August 22, 2024

@Flash3001 The value for pieChartModel.dataSetLegend.Length is flexible. Using live data for this project.

screen shot 2016-08-22 at 10 48 47 am

screen shot 2016-08-22 at 10 59 35 am
screen shot 2016-08-22 at 10 57 07 am

Provided the screenshots, is it what you mentioned more than one PieChartDataSet?

Could not provide you the code due to some reason here. Would you mind show me how is your tests?

from ioscharts.xamarin.

Flash3001 avatar Flash3001 commented on August 22, 2024

The problem is that the PieChart is one-dimensional while a BarChart is bi-dimensional.

            var itens = Enumerable.Range(1, 5);  
            var dataSet = new PieChartDataSet(itens.Select(c => new BarChartDataEntry(c * 20, c)).ToArray(), "Unique");
            dataSet.SliceSpace = 2;
            (dataSet as ChartDataSet).Colors = ChartColorTemplates.Joyful; // Need to fix this property override in the API Definition

            NSObject[] labels =  itens.Select(c => new NSString(c.ToString())).ToArray();

            var minhaView = new iOSCharts.PieChartView(View.Frame);
            minhaView.Data = new iOSCharts.PieChartData(labels, new PieChartDataSet[] { dataSet });

            View.AddSubview(minhaView);
            minhaView.SpinWithDuration(2, 0, 360);

from ioscharts.xamarin.

kevinlcfei avatar kevinlcfei commented on August 22, 2024

@Flash3001 thanks for the sample code. managed to solved the crash issue.

Having UI issue here. Need your understanding of the pie chart view.

pieChartView.DrawSliceTextEnabled = false;
                **pieChartView.HoleColor = chartColors[0];** HERE
                pieChartView.TransparentCircleColor = UIColor.Clear;
                pieChartView.BackgroundColor = UIColor.Clear;
                pieChartView.HoleRadiusPercent = 25f;
                pieChartView.MultipleTouchEnabled = false;
                pieChartView.NoDataTextDescription = "";
                pieChartView.DescriptionText = ""; // Disable description - chartView.SetDescription (String.IsNullOrEmpty (dataModel.name) ? "" : dataModel.name); 
                pieChartView.NoDataText = ""; // Text displayed when no data is given ("You need to provide data for the chart.");

                ChartLegend legend = pieChartView.Legend;
                legend.Position = ChartLegendPosition.BelowChartCenter;
                legend.Form = ChartLegendForm.Square;
                legend.FormSize = 9f;
                legend.XEntrySpace = 15f;
                legend.TextColor = chartTextColor;

                BarChartDataEntry[] pieEntry = new BarChartDataEntry[pieChartModel.yAxis.Count];
                for (int j = 0; j < pieChartModel.yAxis.Count; j++)
                {
                    pieEntry[j] = new BarChartDataEntry((float) pieChartModel.yAxis[j][0], j);
                }

                NSObject[] xData = new NSObject[pieChartModel.dataSetLegend.Length];
                for (int i = 0; i < xData.Length; i++)
                {
                    xData[i] = NSObject.FromObject(pieChartModel.dataSetLegend[i]);
                }

                var yDataSets = new PieChartDataSet(pieEntry, null);
                yDataSets.SliceSpace = 3;
                yDataSets.SelectionShift = 5;
                yDataSets.SetColors(chartColors, 1.0f);

                var data = new PieChartData(xData, new PieChartDataSet[] { yDataSets });
                data.SetValueFormatter(new NSNumberFormatter());
                data.SetValueTextColor(UIColor.Gray);
                data.HighlightEnabled = false;          // Disable highlight selection

                if (pieChartModel.xAxis.Count == 0 && pieChartModel.yAxis.Count == 0
                    || pieChartModel.emptyTableStatus)
                {
                    pieChartView.MultipleTouchEnabled = false;
                    pieChartView.NoDataText = "No Results Were Found."; // Text displayed when no data is given ("You need to provide data for the chart.");
                    pieChartView.HoleRadiusPercent = 0f;

                    if (!pieChartView.IsEmpty)
                        pieChartView.Clear();
                }
                else
                {
                    pieChartView.MultipleTouchEnabled = true;
                    pieChartView.Data = data;
                }

                if (animateChart)
                    pieChartView.SpinWithDuration(2, 0, 360);

image
Hightlighted and Italics text copy screen (Look for "HERE" keyword)

image
Commented the pieChartView.HoleColor result copy screen.

Q: The pie chart did not show the expected result. Does the Hole are causing the issue or dataset(checked its consists of data.) is caused it?

from ioscharts.xamarin.

Flash3001 avatar Flash3001 commented on August 22, 2024

@kevinlcfei I believe I can't help this time. I'm not that expert but you can take a look at this code and see how it works:

https://github.com/danielgindi/Charts/blob/ac2050f343c235f5abbd71bb2daa1872f09ecf0e/Source/Charts/Renderers/PieChartRenderer.swift#L543

If it doesn't help you might create an issue on the original library repo:

https://github.com/danielgindi/Charts/issues

I'm sorry for taking so long to give you an answer and not the best one.

from ioscharts.xamarin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.