예제 #1
0
 public ActionResult IndexLineChart(string indexCode)
 {
     IndexChartModels model = new IndexChartModels();
     model.indexCode = indexCode;
     return View(model);
 }
예제 #2
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;
            }
        }