TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cassie Mod
NA
488
70.5k
Writing command different so it would be less typing.
Jan 28 2016 9:37 AM
HI,
Ive got the following script ( wich works perfectly), but i was wundering is it possible to rewrite "data" so it would use less code ( i'm new to asp.net so it would probably be possible ).
questions:
1: how to rewrite data so it would use less code
2. What linQ command should i use to get an array of all CollectorID's of @Model.CollectorStatus So i could replace that for categories in the script.
other example: @Model.CollectorStatus.Count(c => c.BatchCompleted == true && c.CollectorID==1) // now i need a code to get the array.
Code:
<script type=
"text/javascript"
>
$(document).ready(function () {
$(
"#collectorscompleted"
).kendoChart({
legend: {
visible:
false
},
seriesDefaults: {
type:
"column"
},
series: [{
name:
"Completed"
,
data: [@Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID==1), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 2), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 3), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 4),
@Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 5), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 6), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 7), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 8),
@Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 9), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 10), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 13), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 14),
@Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 15), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 16), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 17), @Model.CollectorStatus.Count(c => c.BatchCompleted ==
true
&& c.CollectorID == 18)]
// This needs to be in less code
}, {
name:
"Failed"
,
data: [@Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID==1), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 2), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 3), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 4),
@Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 5), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 6), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 7), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 8),
@Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 9), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 10), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 13), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 14),
@Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 15), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 16), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 17), @Model.CollectorStatus.Count(c => !c.BatchCompleted ==
true
&& c.CollectorID == 18)]
// this needs to be in less code
}],
valueAxis: {
labels: {
visible:
false
},
line: {
visible:
false
},
majorGridLines: {
visible:
false
}
},
categoryAxis: {
categories: [1,2,3,4,5,6,7,8,9,10,13,14,15,16,17,18],
// needs to be replaces
line: {
visible:
false
},
majorGridLines: {
visible:
false
}
},
chartArea: {
background:
"none"
},
tooltip: {
visible:
true
,
format:
"{0}"
,
template
:
"#= series.name #: #= value #"
}
});
});
</script>
Reply
Answers (
0
)
how to get image source
Get value from rewrited url in controller in mvc