Asp.net mvc ShieldUI线图示例的问题-绑定到本地数据
我试着效仿。我想使用视图模型作为数据源。在视图中,它需要一个静态方法Asp.net mvc ShieldUI线图示例的问题-绑定到本地数据,asp.net-mvc,charts,linegraph,shieldui,Asp.net Mvc,Charts,Linegraph,Shieldui,我试着效仿。我想使用视图模型作为数据源。在视图中,它需要一个静态方法GetElectricityPrices()。如何使用非静态方法使其工作 以下是视图模型: public class ElectricityPrices { public int YearPeriod { set; get; } public double PriceHousehold { set; get; } public double PriceIndustry { set; get; } } 下
GetElectricityPrices()
。如何使用非静态方法使其工作
以下是视图模型:
public class ElectricityPrices
{
public int YearPeriod { set; get; }
public double PriceHousehold { set; get; }
public double PriceIndustry { set; get; }
}
下面是视图中的代码
@(Html.ShieldChart(<ProjectName>.Controllers.<NameController>.GetElectricityPrices())
.Name("chart")
.Theme("light")
...
}函数的返回类型是
IEnumerable
Html.ShieldChart()
构造函数可以接受任何类型的IEnumerable
集合,这允许您使用.Data(…)
方法为定义到图表的每个系列创建映射。函数的返回类型是IEnumerable
Html.ShieldChart()
构造函数可以接受任何类型的IEnumerable
集合,这允许您使用.Data(…)
方法为定义到图表的每个系列创建映射
public static ElectricityPrices[] GetElectrictyPrices()
{
ElectricityPrices[] prices =
{
new ElectricityPrices { YearPeriod = 2001, PriceHousehold = 0.164, PriceIndustry = 0.103 },
new ElectricityPrices { YearPeriod = 2002, PriceHousehold = 0.173, PriceIndustry = 0.105 },
new ElectricityPrices { YearPeriod = 2003, PriceHousehold = 0.184, PriceIndustry = 0.112 },
new ElectricityPrices { YearPeriod = 2004, PriceHousehold = 0.167, PriceIndustry = 0.111 },
new ElectricityPrices { YearPeriod = 2005, PriceHousehold = 0.177, PriceIndustry = 0.102 },
new ElectricityPrices { YearPeriod = 2006, PriceHousehold = 0.189, PriceIndustry = 0.099 },
new ElectricityPrices { YearPeriod = 2007, PriceHousehold = 0.18, PriceIndustry = 0.011 },
new ElectricityPrices { YearPeriod = 2008, PriceHousehold = 0.183, PriceIndustry = 0.113 },
new ElectricityPrices { YearPeriod = 2009, PriceHousehold = 0.188, PriceIndustry = 0.117 },
new ElectricityPrices { YearPeriod = 2010, PriceHousehold = 0.16, PriceIndustry = 0.119 },
new ElectricityPrices { YearPeriod = 2011, PriceHousehold = 0.176, PriceIndustry = 0.123 },
new ElectricityPrices { YearPeriod = 2012, PriceHousehold = 0.178, PriceIndustry = 0.117 },
};
return prices;