Files
LeafWeb/Web/Controllers/LeafCharterController.cs
T
poprhythm 279551e9be Rename Core Models to Core Entities
modified:   Core.Tests/Charter/CurveDataConverterTests.cs
	modified:   Core.Tests/Parsers/CntrlComparisonParserTests.cs
	modified:   Core.Tests/Parsers/LeafInputCsvParserTests.cs
	modified:   Core.Tests/Remote/PiscalSshClientTests.cs
	modified:   Core/Charter/CurveDataConverter.cs
	modified:   Core/Core.csproj
	modified:   Core/DAL/DataService.cs
	modified:   Core/DAL/LeafWebContext.cs
	modified:   Core/DAL/LeafWebInitializer.cs
	renamed:    Core/Models/CntrlComparison.cs -> Core/Entities/CntrlComparison.cs
	renamed:    Core/Models/CntrlComparisonFittingInfo.cs -> Core/Entities/CntrlComparisonFittingInfo.cs
	renamed:    Core/Models/CntrlComparisonPhotosyntheticInfo.cs -> Core/Entities/CntrlComparisonPhotosyntheticInfo.cs
	renamed:    Core/Models/FluxnetSite.cs -> Core/Entities/FluxnetSite.cs
	renamed:    Core/Models/LeafInput.cs -> Core/Entities/LeafInput.cs
	renamed:    Core/Models/LeafInputData.cs -> Core/Entities/LeafInputData.cs
	renamed:    Core/Models/LeafInputFile.cs -> Core/Entities/LeafInputFile.cs
	renamed:    Core/Models/LeafInputInfo.cs -> Core/Entities/LeafInputInfo.cs
	renamed:    Core/Models/LeafInputPhotosynthetic.cs -> Core/Entities/LeafInputPhotosynthetic.cs
	renamed:    Core/Models/LeafInputSite.cs -> Core/Entities/LeafInputSite.cs
	renamed:    Core/Models/LeafInputStatus.cs -> Core/Entities/LeafInputStatus.cs
	renamed:    Core/Models/PhotosynthesisType.cs -> Core/Entities/PhotosynthesisType.cs
	modified:   Core/Parsers/CntrlComparisonParser.cs
	modified:   Core/Parsers/FluxnetSiteCsvParser.cs
	modified:   Core/Parsers/LeafInputCsvParser.cs
	modified:   Web/Controllers/LeafCharterController.cs
	modified:   Web/Controllers/LeafInputController.cs
	modified:   Web/ViewModels/LeafInput/CreateViewModel.cs
2016-02-09 15:27:16 -05:00

93 lines
2.4 KiB
C#

using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
using LeafWeb.Core.Charter;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Parsers;
using LeafWeb.Web.Charter;
namespace LeafWeb.Web.Controllers
{
public class LeafCharterController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult LeafCharts(int number)
{
var fileInfo = new FileInfo(@"C:\Users\poprhythm\Documents\code\LeafWeb\Core.Tests\Parsers\LeafOutputData\cntrlcomparison_Wild Capsicum.csv");
CntrlComparison[] cntrlComparison;
using (var parser = new CntrlComparisonParser(fileInfo))
cntrlComparison = parser.Parse();
var curveData = CurveDataConverter.Convert(cntrlComparison).ToArray();
var charts = LeafWebCharter.ProduceCharts(curveData[2]);
using (var ms = new MemoryStream())
{
charts.Skip(number).First().SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
}
}
public ActionResult ChartSample()
{
var chart = new Chart
{
BackColor = Color.FromArgb(255, 255, 255),
Width = Unit.Pixel(250),
Height = Unit.Pixel(2500)
};
var series = new Series
{
ChartArea = "ca1",
ChartType = SeriesChartType.Line
};
//series.Font = new Font("Verdana", 8.25f, FontStyle.Regular);
var myRandom = new Random();
for (int i = 0; i < 100; i++)
{
var dp = new DataPoint();
dp.AxisLabel = String.Format("{0}-{1}", i, Guid.NewGuid().ToString().Substring(0, 4));
dp.YValues = new double[] { myRandom.Next(5, 100) };
series.Points.Add(dp);
}
chart.Series.Add(series);
var area = new ChartArea("ca1");
area.Area3DStyle.Enable3D = false;
area.AxisX.Interval = 1;
//area.BackColor = Color.Transparent;
//var labelStyle = new LabelStyle();
//labelStyle.Enabled = true;
//labelStyle.Font = new Font("Arial", 3f);
area.AxisX.LabelStyle.Font = new Font("Verdana", 8.25f, FontStyle.Underline);//Why does it recognize the style but not the font!!!???
chart.ChartAreas.Add(area);
using (var ms = new MemoryStream())
{
chart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
}
}
}
}