score:1
Accepted answer
your plugin expects an array of values, but your passing it a string
by using string.join()
.
pass the array using
viewbag.salecount_list = salescount;
viewbag.teamname_list = teamslist;
(or better pass a view model with 2 ienumerable<string>
properties) and then convert it to a jacascript array
var salecounts = @html.raw(json.encode(viewbag.salecount_list))
var teamnames = @html.raw(json.encode(viewbag.teamname_list))
var barchartdata =
{
labels: teamnames,
datasets: [{
....
],
borderwidth: 2,
data: salecounts
}]
};
score:0
using your current syntax:
const string quote = "\"";
foreach (var team in db.teams)
{
teamslist.add(quote + team.name + quote);
int count = db.leadcampaigns.count(i => db.agents.firstordefault(a => a.agentid == i.agentid).teamid == team.teamid && i.leadstatusid == db.leadstatuses.firstordefault(s => s.name == "sale").leadstatusid);
salescount.add(count.tostring());
}
Source: stackoverflow.com
Related Query
- ChartJs Uncaught ReferenceError for labels value from ViewBag
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- ChartJS with ChartJS DataLabels: Change Color per Dataset for Value Labels
- getting additional value fields from data source for dx.chartjs doughnut chart
- Chartjs random colors for each part of pie chart with data dynamically from database
- Truncating canvas labels in ChartJS while keeping the full label value in the tooltips
- how to change Y axis value dynamically based on user input in Chartjs for Line chart?
- Chartjs break line for axes tick labels text
- Side effects from Chartjs for only *some* clients
- How to remove bars for those bars with zero value in Chartjs bar chart?
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- ChartJS How to set max labels for X axis?
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- Setting Common labels and background color common for all the charts in ChartJs
- Minimum value for x Axis doesn't work for horizontal bar chart | ChartJS
- Chartjs - Add backgroundColor for labels radar chart
- Chartjs not working with d3 from csv source
- how can i send a list of numbers from views.py to a chartjs file im using for the front?
- How to prevent tick labels from "jumping" when drawn with ChartJS BeforeDraw
- Hide labels from pie chart in chartjs
- Click on interactive chart.js bar chart and get value for labels and groups in JS
- ChartJS - Scale x axis labels from single days to multiple months
- Skip labels when associated value is null in chartJS
- ChartJS multiple sub labels for label
- ChartJS 3.7.1 tooltip callback, get label value for the next index
- Chartjs : Can I overwrite bar value on hover for every bar chart
- Resize Chart Independently From Legend in ChartJS for Canvas Download
- ChartJS have xAxes labels match data source
- Chartjs showing labels for bidimensional array
- ChartJS - zIndex value for points/tooltips?
More Query from same tag
- Single bar with background Chart.js
- ChartJS horizontal chart display legend on each bar
- How to get any y value for specified x in chart.js?
- Is there a way to hide/customize ChartJS' above legend?
- How to increase Chart.js yAxes' height to prevent overlapping
- Returning fetched JSON correctly but can't get it into Chart.JS
- chart.js reduce file size
- How can I create a stacked bar chart with Charts.JS that displays relative rather than absolute values?
- javascript chart.js remove last point
- Using data from API with Chart JS
- How to include Chart.js in my AngularJS project?
- ChartDataLabels is globally active for some reason
- chartjs not following height when parent's height is 200px
- How to target only X or Y value in jsonObj array
- How to add an extra legend item in chart.js?
- How Can customize chartjs doughnut chart border and tooltip
- Align rotated text to left of canvas
- start y-axis from 0 in ng2-charts
- How to align multiple pie charts side by side?
- Chart Js, Style some ticks on the axis differently
- ChartJS2 in Ionic2
- pass array to chart.js option
- Ionic using multiple chart.js canvas in the same page
- Chart.js how to set start and end values to plot
- How can I create a horizontal scroll effect with angular-chart.js and chart.js
- How to order a horizontal bar chart - chartJS & Chart.HorizontalBar.js
- Labeling and Data (ChartJS)
- React & Chartjs: How can I best destroy my chart when re-rendering?
- How to update a chart taking by querying a database?
- Chart.js category y-axis line chart