Asp.net mvc 4 DotNet.Highcharts包问题
我正在学习一个教程 当我构建应用程序时,我会收到错误消息 找不到类型或命名空间名称“DotNet”是否缺少using指令或程序集引用 我的控制器里有Asp.net mvc 4 DotNet.Highcharts包问题,asp.net-mvc-4,dotnethighcharts,Asp.net Mvc 4,Dotnethighcharts,我正在学习一个教程 当我构建应用程序时,我会收到错误消息 找不到类型或命名空间名称“DotNet”是否缺少using指令或程序集引用 我的控制器里有 using HighChart.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DotNet.Highcharts; using DotNet.Highch
using HighChart.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DotNet.Highcharts;
using DotNet.Highcharts.Helpers;
using DotNet.Highcharts.Options;
using DotNet.Highcharts.Enums;
在这张照片中,网络下有一个蓝色的曲线。
以及“我的参考资料”文件夹中的参考DotNet.Highcharts
如果这很重要,我正在使用VS 2012 Professional
我需要在我的网络配置中添加我丢失的内容,还是需要设置引用路径?我以前使用过nuget软件包,没有遇到过这个问题,所以不确定我需要做什么
我所做的一切
重新启动VS
关闭/重新打开项目
从头开始项目MVC4empty并添加到nuget的DotNet.Highcharts和Jquery包中,并遵循上面列出的教程。
模型
控制器
using HighChart.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DotNet.Highcharts;
using DotNet.Highcharts.Helpers;
using DotNet.Highcharts.Options;
using DotNet.Highcharts.Enums;
namespace HighChart.Controllers
{
public class ChartSampleController : Controller
{
//
// GET: /ChartSample/
public ActionResult Index()
{
var transactionCounts = new List<TransactionCount> {
new TransactionCount() { MonthName="January", Count=30},
new TransactionCount() { MonthName="February", Count=40},
new TransactionCount() { MonthName="March", Count=4},
new TransactionCount() { MonthName="April", Count=35}
};
var xDataMonths = transactionCounts.Select(i => i.MonthName).ToArray();
var yDataCounts = transactionCounts.Select(i => new object[] { i.Count }).ToArray();
//instanciate an object o the highcharts type
var chart = new Highcharts("chart")
//define the type of chart
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
//overall title of the chart
.SetTitle(new Title { Text = "Incoming Transactions per hour" })
//small lable below the main title
.SetSubtitle(new Subtitle { Text = "Accounting" })
//load the X values
.SetXAxis(new XAxis { Categories = xDataMonths })
//set the Y Title
.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Number of Transactions" } })
.SetTooltip(new Tooltip
{
Enabled = true,
Formatter = @"function () { return '<b>' + this.series.name + '</b><br/>'+ this.x +': '+ this.y; }"
})
.SetPlotOptions(new PlotOptions
{
Line = new PlotOptionsLine
{
DataLabels = new PlotOptionsLineDataLabels
{
Enabled = true
},
EnableMouseTracking = false
}
})
//load the Y values
.SetSeries(new[]
{
new Series {Name = "Hour", Data = new Data(yDataCounts)},
//you can add more y data to create a second line
// new series { Name = "Other Name", Data = new Data(OtherData)}
});
return View(chart);
//return View();
}
}
}
看法
任何帮助都将不胜感激!提前感谢您是否将dll添加到引用中?您需要通过浏览dll位置手动执行此操作 就我而言,我必须专门下载NET4.0DLL。 我真的以为nuget软件包会解决这个问题
using HighChart.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DotNet.Highcharts;
using DotNet.Highcharts.Helpers;
using DotNet.Highcharts.Options;
using DotNet.Highcharts.Enums;
namespace HighChart.Controllers
{
public class ChartSampleController : Controller
{
//
// GET: /ChartSample/
public ActionResult Index()
{
var transactionCounts = new List<TransactionCount> {
new TransactionCount() { MonthName="January", Count=30},
new TransactionCount() { MonthName="February", Count=40},
new TransactionCount() { MonthName="March", Count=4},
new TransactionCount() { MonthName="April", Count=35}
};
var xDataMonths = transactionCounts.Select(i => i.MonthName).ToArray();
var yDataCounts = transactionCounts.Select(i => new object[] { i.Count }).ToArray();
//instanciate an object o the highcharts type
var chart = new Highcharts("chart")
//define the type of chart
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
//overall title of the chart
.SetTitle(new Title { Text = "Incoming Transactions per hour" })
//small lable below the main title
.SetSubtitle(new Subtitle { Text = "Accounting" })
//load the X values
.SetXAxis(new XAxis { Categories = xDataMonths })
//set the Y Title
.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Number of Transactions" } })
.SetTooltip(new Tooltip
{
Enabled = true,
Formatter = @"function () { return '<b>' + this.series.name + '</b><br/>'+ this.x +': '+ this.y; }"
})
.SetPlotOptions(new PlotOptions
{
Line = new PlotOptionsLine
{
DataLabels = new PlotOptionsLineDataLabels
{
Enabled = true
},
EnableMouseTracking = false
}
})
//load the Y values
.SetSeries(new[]
{
new Series {Name = "Hour", Data = new Data(yDataCounts)},
//you can add more y data to create a second line
// new series { Name = "Other Name", Data = new Data(OtherData)}
});
return View(chart);
//return View();
}
}
}
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-2.1.3.min.js"></script>
<script src="~/Scripts/Highcharts-4.0.1/js/highcharts.js"></script>
</head>
<body>
<div>
@model DotNet.Highcharts.Highcharts
<p>My Chart</p>
@(Model)
</div>
</body>
</html>