예제 #1
0
        public BubbleChartPage()
        {
            InitializeComponent();

            var entries  = new List <BubbleEntry>();
            var entries2 = new List <BubbleEntry>();
            var labels   = new List <string>();

            Random random = new Random();

            for (int i = 0; i < 8; i++)
            {
                entries.Add(new BubbleEntry(i, random.Next(8), random.Next(20)));
                entries2.Add(new BubbleEntry(i, random.Next(8), random.Next(20)));
                labels.Add("Entry" + i);
            }

            var dataSet4 = new BubbleDataSet(entries, "Bubble DataSet 1")
            {
                Colors = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
            };
            var dataSet5 = new BubbleDataSet(entries2, "Bubble DataSet 2")
            {
                Colors = new List <Color> {
                    Color.Green
                },
            };

            var data4 = new BubbleChartData(new List <IBubbleDataSet>()
            {
                dataSet4
            });

            chart.ChartData             = data4;
            chart.DescriptionChart.Text = "Test label chart description";

            chart.AxisLeft.DrawGridLines = false;
            chart.AxisLeft.DrawAxisLine  = true;
            chart.AxisLeft.Enabled       = true;

            chart.AxisRight.DrawAxisLine  = false;
            chart.AxisRight.DrawGridLines = false;
            chart.AxisRight.Enabled       = false;

            chart.XAxis.DrawGridLines      = false;
            chart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);
        }
        /*
         * EXPORT FOR BUBBLE
         */
        public BubbleData ExportBubbleData(Widget.Charts.Models.BubbleChart.BubbleChartData bubbleChartData)
        {
            var dataSetItems = new List <BubbleDataSet>();

            foreach (var item in bubbleChartData.DataSets)
            {
                var entryOriginal = item.IF_GetValues().Select(obj => new BubbleEntry(obj.GetXPosition(), obj.GetYPosition(), obj.GetSize()));
                var dataSet       = new BubbleDataSet(entryOriginal.ToArray(), item.IF_GetLabel());
                OnIntializeDataSetBubble(item, dataSet);
                dataSetItems.Add(dataSet);
            }
            var data = new BubbleData(dataSetItems.ToArray());

            return(data);
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();
            var entrieLine = new List <EntryChart>();
            var entries    = new List <BubbleEntry>();
            var entries2   = new List <BubbleEntry>();
            var labels     = new List <string>();

            Random random = new Random();


            for (int i = 0; i < 8; i++)
            {
                entrieLine.Add(new EntryChart(i, random.Next(20)));
                entries.Add(new BubbleEntry(i, random.Next(8), random.Next(20)));
                entries2.Add(new BubbleEntry(i, random.Next(8), random.Next(20)));
                labels.Add("Entry" + i);
            }

            var entriesCandle = new List <CandleStickEntry>();

            entriesCandle.Add(new CandleStickEntry(0, 4.62f, 2.02f, 2.70f, 4.13f));
            entriesCandle.Add(new CandleStickEntry(1, 5.50f, 2.70f, 3.35f, 4.96f));
            entriesCandle.Add(new CandleStickEntry(2, 5.25f, 3.02f, 3.50f, 4.50f));
            entriesCandle.Add(new CandleStickEntry(3, 6f, 3.25f, 4.40f, 5.0f));
            entriesCandle.Add(new CandleStickEntry(4, 5.57f, 2f, 2.80f, 4.5f));

            var dataSetBubble = new BubbleDataSet(entries, "Bubble DataSet 1")
            {
                Colors = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
            };
            var dataBubble = new BubbleChartData(new List <IBubbleDataSet>()
            {
                dataSetBubble
            });


            var dataSetCandle = new CandleStickDataSet(entriesCandle, "Candle Stick DataSet 1")
            {
                DecreasingColor = Color.Red,
                IncreasingColor = Color.Green
            };
            var dataCandle = new CandleStickChartData(new List <ICandleStickDataSet>()
            {
                dataSetCandle
            });


            var dataSetLine = new LineDataSetXF(entrieLine, "Line DataSet 1")
            {
                CircleRadius     = 10,
                CircleHoleRadius = 4f,
                CircleColors     = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
                CircleHoleColor = Color.Green,
                Mode            = LineDataSetMode.CUBIC_BEZIER
            };
            var dataLine = new LineChartData(new List <ILineDataSetXF>()
            {
                dataSetLine
            });


            var dataSetbar = new BarDataSet(entrieLine, "Bar DataSet 1")
            {
                Colors = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
            };
            var dataBar = new BarChartData(new List <IBarDataSet>()
            {
                dataSetbar
            });

            var combinData = new CombinedChartData(null);

            combinData.BubbleChartData      = dataBubble;
            combinData.CandleStickChartData = dataCandle;
            combinData.LineChartData        = dataLine;
            combinData.BarChartData         = dataBar;
            chart.ChartData = combinData;
            chart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);
        }