public ActionResult PriceHistoryChart(ObjectId id) { var product = _ProductRepo.Get(id); if (product == null) return new EmptyResult(); // 过去30天 var days = Enumerable.Range(-30, 31).Select(d => DateTime.Today.AddDays(d)); var chart = new FusionChartsDriver.MSStepLine(); chart.Chart = new FusionChartsDriver.Chart { ShowValues = 0, BgColor = "ffffff", ShowBorder = 0, Animation = 0, FormatNumberScale = 0, }; chart.Categories = new[] { new FusionChartsDriver.Categories { CategoryCollection = days.Select(d => new FusionChartsDriver.Category { Label = d.ToString("M-d") }) } }; chart.Dataset = new[]{ new FusionChartsDriver.DataSet { Data = days.Select(d=> { var price = _PriceHistoryRepo.GetPriceInDay(id, d); return new FusionChartsDriver.Data { Value = price, ToolText = string.Format("{0}月{1}日价格 {2:C}", d.Month, d.Day, price) }; }) } }; return Content(chart.ToJson()); }
public ActionResult PriceHistoryChart(ObjectId id) { var product = _ProductRepo.Get(id); if (product == null) { return(new EmptyResult()); } // 过去30天 var days = Enumerable.Range(-30, 31).Select(d => DateTime.Today.AddDays(d)); var chart = new FusionChartsDriver.MSStepLine(); chart.Chart = new FusionChartsDriver.Chart { ShowValues = 0, BgColor = "ffffff", ShowBorder = 0, Animation = 0, FormatNumberScale = 0, }; chart.Categories = new[] { new FusionChartsDriver.Categories { CategoryCollection = days.Select(d => new FusionChartsDriver.Category { Label = d.ToString("M-d") }) } }; chart.Dataset = new[] { new FusionChartsDriver.DataSet { Data = days.Select(d => { var price = _PriceHistoryRepo.GetPriceInDay(id, d); return(new FusionChartsDriver.Data { Value = price, ToolText = string.Format("{0}月{1}日价格 {2:C}", d.Month, d.Day, price) }); }) } }; return(Content(chart.ToJson())); }