0
Beantwortet
OxyPlot : integration in website/webservice
Hi
I was wondering if it’s possible to use OxyPlot for exporting .png files on the fly that are shown in a website.
From what I know I can use it within Winforms / WPF.
But my goal is to have the plotviews available in my website.
We already have an webservice (.NET 4.0). Is it possible to integrate OxyPlot there?
I don’t want a dirty solution to start an external exe in the webpage/webservice that generates the PNG.
Maybe you’ve got an idea?
With kind regards,
I was wondering if it’s possible to use OxyPlot for exporting .png files on the fly that are shown in a website.
From what I know I can use it within Winforms / WPF.
But my goal is to have the plotviews available in my website.
We already have an webservice (.NET 4.0). Is it possible to integrate OxyPlot there?
I don’t want a dirty solution to start an external exe in the webpage/webservice that generates the PNG.
Maybe you’ve got an idea?
With kind regards,
Customer support service by UserEcho
Here is an example using WebAPI:
namespace WebApplication4.Controllers { using System; using System.IO; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Web.Http; using OxyPlot; using OxyPlot.Series; using OxyPlot.WindowsForms; public class PlotsController : ApiController { public HttpResponseMessage Get(int id) { var model = new PlotModel { Title = "Plot #" + id }; model.Series.Add(new FunctionSeries(Math.Sqrt, 0, 100, 0.01, "sqrt(x)")); var memoryStream = new MemoryStream(); var exporter = new PngExporter(); exporter.Export(model, memoryStream); var result = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new ByteArrayContent(memoryStream.ToArray()) }; result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline") { FileName = string.Format("plot{0}.png", id) }; return result; } } }The result is:OxyPlot.WindowsForms_NET35.csproj
Big thanks!