Beispiel #1
0
        public async void GetList()
        {
            await Task.Run(() =>
            {
                //007301
                //161725
                var data                    = WebTool.GetFunDetail(_RESTService, "161725").data;
                LineVm.ChartTitle           = data.name;
                UnitLineVm.ChartTitle       = data.name;
                List <List <string> > worth = data.netWorthData;
                List <WorthBase> datas      = new List <WorthBase>();
                foreach (List <string> arr in worth)
                {
                    WorthBase worthBase = new WorthBase(DateTime.Parse(arr[0]), arr[1], arr[2]);
                    datas.Add(worthBase);
                }

                datas = datas.Where(p => p.Date >= DateTime.Parse("2020-01-01")).ToList();
                foreach (var dt in datas)
                {
                    ChartDataBase line_data = new ChartDataBase("净值涨幅", dt.Date,
                                                                string.Format("{0}", dt.Rate));

                    this.LineVm.DataSource.Add(line_data);
                    LineVm.DataSource.Add(new ChartDataBase("单位净值", dt.Date,
                                                            string.Format("{0}", dt.Unit_worth)));

                    UnitLineVm.DataSource.Add(new ChartDataBase("单位净值", dt.Date,
                                                                string.Format("{0}", dt.Unit_worth)));
                }
            });
        }
Beispiel #2
0
        public List <object> LoadGrid()
        {
            List <ChartDataBase> datas = new List <ChartDataBase>();
            int i = 0;

            while (i < 100)
            {
                ChartDataBase dt = new ChartDataBase("Main", DateTime.Now, i.ToString());
                datas.Add(dt);
                i++;
            }
            List <object> data = datas.Cast <object>().ToList();

            return(data);
        }
Beispiel #3
0
        public override ChartDataBase GetChartData()
        {
            var data = GetData();

            var chartData = new ChartDataBase {
                ChartType = ChartType.Bar
            };

            var labels       = new List <string[]>();
            var chartDataSet = new List <BarDataSet>();

            var residents = new BarDataSet {
                Label = "Национальные заявители", Data = new double[data.Rows.Count], BackgroundColor = "#2c8ebb", BorderColor = "#2c8ebb"
            };
            var nonResidents = new BarDataSet {
                Label = "Иностранне заявители", Data = new double[data.Rows.Count], BackgroundColor = "#b56b2c", BorderColor = "#b56b2c"
            };

            var dataNumber = 0;

            for (int i = 0; i < data.Rows.Count - 1; i++)
            {
                var row = data.Rows[i];
                if (row.IsHeader == false)
                {
                    residents.Data[dataNumber]    = row.Cells[2].Value;
                    nonResidents.Data[dataNumber] = row.Cells[3].Value;

                    dataNumber++;

                    string label = row.Cells[1].Value.ToString();

                    labels.Add(label.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            chartDataSet.Add(residents);
            chartDataSet.Add(nonResidents);

            chartData.Labels   = labels;
            chartData.Datasets = chartDataSet.ToArray();

            return(chartData);
        }
Beispiel #4
0
        public override ChartDataBase GetChartData()
        {
            var data = GetData();

            var chartData = new ChartDataBase {
                ChartType = ChartType.Bar
            };

            var labels       = new List <string[]>();
            var chartDataSet = new List <BarDataSet>();

            var residents = new BarDataSet {
                Label = "Национальные заявители", Data = new double[data.Rows.Count], BackgroundColor = "#2c8ebb", BorderColor = "#2c8ebb"
            };
            var nonResidents = new BarDataSet {
                Label = "Иностранне заявители", Data = new double[data.Rows.Count], BackgroundColor = "#b56b2c", BorderColor = "#b56b2c"
            };
            var sum = new BarDataSet {
                Label = "Всего", Data = new double[data.Rows.Count], BackgroundColor = "#cccccc", BorderColor = "#cccccc"
            };

            var dataNumber = 0;

            for (int i = 0; i < data.Rows.Count; i++)
            {
                //Пропускаем общее количество
                if (i == 10)
                {
                    continue;
                }

                var row = data.Rows[i];

                //workaround для общеизвестных, отображал некорректно
                if (i == 11)
                {
                    residents.Data[dataNumber]    = row.Cells[3].Value ?? 0;
                    nonResidents.Data[dataNumber] = row.Cells[4].Value ?? 0;
                    sum.Data[dataNumber]          = residents.Data[dataNumber] + nonResidents.Data[dataNumber];

                    dataNumber++;

                    string label = row.Cells[1].Value.ToString();

                    labels.Add(label.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                    continue;
                }
                //остальные типы
                if (row.IsHeader == false)
                {
                    if (dataNumber < 5)
                    {
                        residents.Data[dataNumber]    = row.Cells[2].Value ?? 0;
                        nonResidents.Data[dataNumber] = row.Cells[3].Value ?? 0;
                    }
                    else
                    {
                        try
                        {
                            residents.Data[dataNumber]    = row.Cells[4].Value ?? 0;
                            nonResidents.Data[dataNumber] = row.Cells[5].Value ?? 0;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    sum.Data[dataNumber] = residents.Data[dataNumber] + nonResidents.Data[dataNumber];

                    dataNumber++;

                    string label = row.Cells[1].Value.ToString();

                    labels.Add(label.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            chartDataSet.Add(residents);
            chartDataSet.Add(nonResidents);
            chartDataSet.Add(sum);

            chartData.Labels   = labels;
            chartData.Datasets = chartDataSet.ToArray();

            return(chartData);
        }