|
|
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 Column3DNullValues()
{
List<double?> chartValues = new List<double?> { 2, 3, null, 4, 0, 5, 1, 4, 6, 3 };
List<ColumnSeriesData> chartData = new List<ColumnSeriesData>();
chartValues.ForEach(p => chartData.Add(new ColumnSeriesData { Y = p }));
ViewData["chartData"] = chartData;
return View();
}
}
}
Controller Code
<script src="https://code.highcharts.com/highcharts.js"></script>
@*All Highcharts 3D charts requires the highcharts-3rd.js module*@
<script src="https://code.highcharts.com/highcharts-3d.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
{
Chart = new Highsoft.Web.Mvc.Charts.Chart
{
Margin = new double[1] { 75 },
Options3d = new ChartOptions3d
{
Enabled = true,
Alpha = 10,
Beta = 25,
Depth = 70
}
},
Title = new Title
{
Text = "3D chart with null values"
},
Subtitle = new Subtitle
{
Text = "Notice the difference between a 0 value and a null point"
},
PlotOptions = new PlotOptions
{
Column = new PlotOptionsColumn
{
Depth = 25
}
},
XAxis = new List<XAxis>
{
new XAxis
{
Categories = new List<string> { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
}
},
YAxis = new List<YAxis>
{
new YAxis
{
Title = new YAxisTitle
{
Text = null
}
}
},
Series = new List<Series>
{
new ColumnSeries
{
Name = "Sales",
Data = @ViewData["chartData"] as List<ColumnSeriesData>
}
}
};
chartOptions.ID = "chart";
var renderer = new HighchartsRenderer(chartOptions);
}
@Html.Raw(renderer.RenderHtml())