|
|
Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Highsoft.Web.Mvc.Charts;
namespace MVC_Demo.Areas.Highcharts.Controllers.Shared
{
public partial class SharedController : Controller
{
public ActionResult ComboRegression()
{
return View();
}
}
}
Controller Code
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
@using Highsoft.Web.Mvc.Charts
@using Highsoft.Web.Mvc.Charts.Rendering
@{ var chartOptions =
new Highcharts
{
Title = new Title
{
Text = "Scatter plot with regression line",
X = -20
},
XAxis = new List<XAxis>
{
new XAxis
{
Title = new XAxisTitle
{
Text = "Scatter plot with regression line",
X = -20
}
}
},
YAxis = new List<YAxis>
{
new YAxis
{
Min = 0
}
},
Series = new List<Series>
{
new LineSeries
{
Name = "Regression Line",
Marker = new LineSeriesMarker
{
Enabled = false
},
States = new LineSeriesStates
{
Hover = new LineSeriesStatesHover
{
LineWidth = 0
}
},
EnableMouseTracking = false,
Data = new List<LineSeriesData> {
new LineSeriesData { X = 0, Y = 1.11 },
new LineSeriesData { X = 5, Y = 4.51 }
}
},
new ScatterSeries
{
Name = "Observations",
Data = new List<ScatterSeriesData> {
new ScatterSeriesData { Y = 1 },
new ScatterSeriesData { Y = 1.5 },
new ScatterSeriesData { Y = 2.8 },
new ScatterSeriesData { Y = 3.5 },
new ScatterSeriesData { Y = 3.9 },
new ScatterSeriesData { Y = 4.2 },
}
}
}
};
chartOptions.ID = "chart";
var renderer = new HighchartsRenderer(chartOptions);
}
@Html.Raw(renderer.RenderHtml())