Update Charting to use fancybox
This commit is contained in:
@@ -25,6 +25,9 @@ namespace LeafWeb.WebCms.Controllers
|
||||
if (!leafInputId.HasValue)
|
||||
return View("DataError", model: "Must specify LeafInputId");
|
||||
|
||||
//if (leafInputId == 2147483647)
|
||||
// return View(GetTestChartViewModel());
|
||||
|
||||
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId.Value);
|
||||
|
||||
if (leafOutputFile == null)
|
||||
@@ -57,14 +60,28 @@ namespace LeafWeb.WebCms.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult ChartCurve(int leafInputId, string curveId)
|
||||
//private ChartViewModel GetTestChartViewModel()
|
||||
//{
|
||||
// return new ChartViewModel
|
||||
// {
|
||||
// AvailableCurveId = new []{"Valid", "Test"},
|
||||
// LeafInputId = 2147483647,
|
||||
// LeafInputIdentifier = "Chart Tests"
|
||||
// };
|
||||
//}
|
||||
|
||||
public ActionResult ChartCurve(int leafInputId, string curveId, bool base64 = false)
|
||||
{
|
||||
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId);
|
||||
|
||||
if (leafOutputFile == null)
|
||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||
if (leafOutputFile == null)
|
||||
{
|
||||
var logger = LogManager.GetLogger(GetType());
|
||||
logger.Warn($"Invalid LeafInputID {leafInputId}");
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NotFound, $"Invalid LeafInputId {leafInputId}.");
|
||||
}
|
||||
|
||||
CurveData curveData;
|
||||
CurveData curveData;
|
||||
try
|
||||
{
|
||||
curveData = GetCurveData(leafOutputFile.FileContents.Contents, curveId);
|
||||
@@ -75,7 +92,7 @@ namespace LeafWeb.WebCms.Controllers
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NotFound, $"Unhandled exception thrown wihle parsing {leafOutputFile.Filename}.");
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NotFound, $"Unhandled exception thrown while parsing {leafOutputFile.Filename}.");
|
||||
}
|
||||
|
||||
if (curveData == null || curveData.ParamSets.Count == 0)
|
||||
@@ -88,12 +105,14 @@ namespace LeafWeb.WebCms.Controllers
|
||||
foreach (var chart in charts) chart.Dispose(); // cleanup
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
combinedChart.Save(ms, ImageFormat.Png);
|
||||
{
|
||||
combinedChart.Save(ms, ImageFormat.Png);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
var base64String = Convert.ToBase64String(ms.ToArray());
|
||||
return Content(base64String, "image/png");
|
||||
//return File(ms.ToArray(), "image/png", curveId.FilterValidFilename() + ".png");
|
||||
if (base64)
|
||||
return Content(base64String, "image/png");
|
||||
else
|
||||
return File(ms.ToArray(), "image/png", curveId.FilterValidFilename() + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user