Exemplo n.º 1
0
        public FileResult Index(ChartExampleModels model)
        {
            IList<IndexChartModels> indexList = new List<IndexChartModels>();
            IList<MoneyChartModels> moneyList = new List<MoneyChartModels>();
            string[] indexArr = new string[]{};
            string[] moneyArr = new string[] { };
            if (model.indexField != null)
            {
                indexArr = model.indexField.Split(',');
            }
            if (model.moneyField != null)
            {
                moneyArr = model.moneyField.Split(',');
            }

            DateTime date = DateTime.Now;
            for (int i = 0; i < indexArr.Length; i++)
            {
                IndexChartModels obj = new IndexChartModels();
                obj.indexField = indexArr[i];
                obj.strIndexTime = date.ToString("dd/MM/yy");
                indexList.Add(obj);
                date.AddDays(1);
            }

            date = DateTime.Now;
            for (int i = 0; i < moneyArr.Length; i++)
            {
                MoneyChartModels obj = new MoneyChartModels();
                obj.indexMoney = moneyArr[i];
                obj.strIndexTime = date.ToString("dd/MM/yy");
                moneyList.Add(obj);
                date.AddDays(1);
            }

            int width = 700;
            int height = 200;
            try
            {
                width = Int32.Parse(model.width);
            }
            catch
            {
                width = 700;
            }
            try
            {
                height = Int32.Parse(model.height);
            }
            catch
            {
                height = 700;
            }
            try
            {
                return this.CreateColumnChart(indexList, moneyList, width, height, model.titleField);
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Exemplo n.º 2
0
 //
 // GET: /ChartExample/
 public ActionResult Index()
 {
     ChartExampleModels model = new ChartExampleModels();
     model.width = "700";
     model.height = "200";
     return View(model);
 }