我有一个上传功能,它循环选定的文件并将它们添加到服务器文件系统上.
上传工厂
app.factory('uploadFactory', function ($upload, $q) {
var uploadFactory = {};
var image = {
Models: [],
Images: [],
uploadImages: function () {
var defer = $q.defer();
for (var i = 0; i < this.Models.length; i++) {
var $file = this.Models[i].file;
(function (index) {
$upload
.upload({
url: "/api/upload/",
method: "POST",
file: $file
})
.success(function (data, result) {
// Add returned file data to model
var imageObject = {
Path: data.Path,
Description: image.Models[index].Description,
Photographer: image.Models[index].Photographer
};
image.Images.push(imageObject);
defer.resolve(result);
});
})(i);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码扩展Chart.js中的折线图:
var shotsData = {
labels: ["Shot 1", "Shot 2", "Shot 3", "Shot 4", "Shot 5"],
datasets: [{ data: [5, 7, 1, 4, 9] }]
};
var ctx = document.getElementById("shots").getContext("2d");
Chart.types.Line.extend({
name: "LineAlt",
initialize: function () {
this.chart.ctx.beginPath();
this.chart.ctx.moveTo(0, 15);
this.chart.ctx.lineTo(159, 274);
this.chart.ctx.stroke();
Chart.types.Line.prototype.initialize.apply(this, arguments);
}
});
new Chart(ctx).LineAlt(shotsData);
Run Code Online (Sandbox Code Playgroud)
这绘制了我的图表,但我也希望图表中有一个自定义行,它写在initialize函数内部,但这似乎不起作用.当我删除该行时,Chart.types.Line.prototype.initialize.apply(this, arguments);将显示自定义行.
这是一个小提琴
我的用户表:
public class User
{
[Key]
public int UserId { get; set; }
public virtual ICollection<PollVote> PollVotes { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的投票表:
public class Poll
{
[Key]
public int PollId { get; set; }
public virtual ICollection<PollVote> PollVotes { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的投票表
public class PollVote
{
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int VoteId { get; set; }
[Key]
public int PollId { get; set; }
[Key]
public int UserId { get; set; }
public DateTime TimeVoted { get; set; } …Run Code Online (Sandbox Code Playgroud)