Created
February 17, 2018 13:33
-
-
Save joshi-kumar/90a0ede6d311baf02dcbfb47eec645b6 to your computer and use it in GitHub Desktop.
HIGH Chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/members/setoptions/ | |
http://api.highcharts.com/highcharts/yAxis | |
*********************** | |
<Script> | |
@model DotNet.Highcharts.Highcharts | |
@using Nop.Core.Infrastructure; | |
@{ | |
//Html.AppendScriptParts("~/Administration/Scripts/Highcharts-4.0.1/highcharts.js"); | |
//Html.AppendScriptParts("~/Scripts/jquery-1.10.2.min.js"); | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | |
<script src="http://code.highcharts.com/highcharts.js"></script> | |
<script src="http://code.highcharts.com/modules/exporting.js"></script> | |
//Html.AppendScriptParts("https://code.highcharts.com"); | |
ViewBag.Title = "HighCharts"; | |
} | |
@*<h2>HighCharts</h2> | |
Hi | |
@(Model)*@ | |
<script type="text/javascript"> | |
$(function () { | |
debugger; | |
$.ajax({ | |
url: '/AnalyticsAndReports/LineChart', | |
// url: "@Html.Raw(Url.Action("LineChart", "AnalyticsAndReports"))", | |
dataType: "json", | |
type: "GET", | |
contentType: 'application/json; charset=utf-8', | |
async: false, | |
processData: false, | |
cache: false, | |
delay: 15, | |
success: function (data) { | |
// alert(data); | |
var series = new Array(); | |
for (var i in data) { | |
var serie = new Array(data[i].Value, data[i].Item); | |
series.push(serie); | |
} | |
DrawPieChart(series); | |
}, | |
error: function (xhr) { | |
alert('error'); | |
} | |
}); | |
}); | |
function DrawPieChart(series) { | |
alert(series) | |
//$('#container')[0].highcharts({ | |
var chart = new Highcharts.Chart({ | |
chart: { | |
plotBackgroundColor: null, | |
plotBorderWidth: 1, //null, | |
plotShadow: false, | |
renderTo: 'container' | |
}, | |
xAxis: { | |
tickInterval: 1, | |
labels: { | |
enabled: true, | |
formatter: function () { return series[this.value][0]; }, | |
} | |
}, | |
//xAxis: { | |
// categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] | |
//}, | |
//zoneAxis: 'x', | |
//zones: [{ | |
// value: 8 | |
//}, { | |
// dashStyle: 'dot' | |
//}], | |
//}, | |
title: { | |
text: ' Product Browes by Time' | |
}, | |
tooltip: { | |
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' | |
}, | |
plotOptions: { | |
pie: { | |
allowPointSelect: true, | |
cursor: 'pointer', | |
dataLabels: { | |
enabled: false | |
}, | |
showInLegend: true | |
} | |
}, | |
series: [{ | |
type: 'line', | |
name: 'Task Status', | |
data: series | |
}] | |
}); | |
} | |
</script> | |
<div id="container" style="min-width: 350px; height: 350px; max-width: 600px; margin: 0 auto">ff</div> | |
**************** cs file | |
#region High-charts | |
public ActionResult HighCharts() | |
{ | |
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart") | |
.SetXAxis(new XAxis | |
{ | |
Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } | |
}) | |
.SetSeries(new Series | |
{ | |
Data = new DotNet.Highcharts.Helpers.Data(new object[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 }) | |
}); | |
return View(chart); | |
} | |
[HttpGet] | |
public JsonResult LineChart() | |
{ | |
List<HighChartModel> list = new List<HighChartModel>(); | |
var record = _analyticsAndReportService.GetBrowesProduct(); | |
List<int> existing = new List<int>(); | |
foreach (var rc in record) | |
{ | |
var year = rc.CreatedOnUtc.Year; | |
if (existing.Contains(year)) | |
continue; | |
int c = (from q in record | |
where q.CreatedOnUtc.Year == year | |
select q.ProducId).Count(); | |
existing.Add(year); | |
HighChartModel r = new HighChartModel(); | |
r.Item = Convert.ToDouble(c); | |
r.Value =Convert.ToString(rc.CreatedOnUtc.Year); | |
list.Add(r); | |
} | |
list = list.OrderBy(i => i.Value).ToList(); | |
return Json(list, JsonRequestBehavior.AllowGet); | |
} | |
#endregion | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment