score:2
Accepted answer
List is not serializable to web method instead of this you can return object[].
[WebMethod]
public object[] getProgram12Months(string usersessionid)
{
List<object> iData = new List<object>();
List<string> labels = new List<string>();
//First get distinct Month Name for select Year.
string query1 = "SELECT DISTINCT TOP (100) PERCENT TimeFrame FROM dbo.CSQ_ProgramCount12Months ORDER BY TimeFrame ";
string conn = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
SqlDataAdapter dap = new SqlDataAdapter(query1, conn);
DataSet ds = new DataSet();
dap.Fill(ds);
DataTable dtLabels = ds.Tables[0];
foreach (DataRow drow in dtLabels.Rows)
{
labels.Add(drow["TimeFrame"].ToString());
}
iData.Add(labels.ToArray());
return iData.ToArray();
}
score:2
I resolved this by creating two classes an populating them. Thank you er-sho, your posts help lead me in the right direction.
public class ChartData2
{
public List<string> Legends;
public List<int> AD;
}
public class Legend
{
public List<string> Months;
}
Source: stackoverflow.com
Related Query
- Return List<object> from webservice
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- Chartjs not working with d3 from csv source
- return array from ajax
- Passing an Array from a Flask view to the javascript code of another view
- Using Chart.js onClick function, can you execute code from an undefined or null result?
- Angular6 and ng2-charts does not display any charts when i fill data from webservice
- Calling data from outside of Chartjs code
- Ionic not return data from variable
- How do I use the return values from csv ajax request for x and y values?
- getting additional value fields from data source for dx.chartjs doughnut chart
- How to return two lists to chartjs from Django View
- How pass a variable from code behind to javascript
- How to run Chart.js samples using source code
- Return values from nested array
- How to clear a chart from a canvas so that hover events cannot be triggered?
- Change the Y-axis values from real numbers to integers in Chart.js
- chart.js Failed to create chart: can't acquire context from the given item
- How to remove square label from tooltip and make its information in one line?
- Chartjs random colors for each part of pie chart with data dynamically from database
- How do I prevent the scale labels from being cut off in chartjs?
- How to prevent first/last bars from being cut off in a chart with time scale
- Chart.js Bar Chart - how to chart bars from 0
- Chart from chart.js to pdf
- Get Chart js object from selector
- Hide min and max values from y Axis in Chart.js
- how to change the Y-axis values from float number to integer in chartjs?
- ChartJs how to get from mulitiple dateset which dataset bar is clicked
- How to add datas to chart js from javascript array itself?
- Adding Chart.js line chart to Jinja2/Flask html page from JS file
More Query from same tag
- How to collect values of object properties into a list?
- add labels dynamically in Charts.js
- How to bind json array data to chart.js with same canvas id?
- Chartjs: how to remove datapoint info from label?
- Stepped line with null values in chart.js
- Chart.js Pie Chart: How to set background image for segment
- How do I make my Type:Time to work with my Line Chart?
- Data not displaying in Chart JS from PHP JSON
- ReactJS - Moving vertical line when hovering over Line chart using chart.js v3.7.1
- ChartJS - Uncaught SyntaxError: Unexpected number
- Including Chart.js in a webpage without node.js and without CDN
- Uncaught Error: [$injector:modulerr] Error: [$injector:nomod] Module 'chart.js' is not available
- Is it possible to get chart js data using ajax?
- Draw data in graphics generated by Chart JS
- How to put dynamic colors for pie chart - chart js
- Javascript OnChange to update data
- Adding custom text to Bar Chart label values using Chart.js
- How to change font size, padding of chart title only, in chart.js 3.x
- angular chartjs line chart default options
- chartjs tooltip is cut off when out of canvas
- Angular 6 Charting Google Sheets API Data
- I need to increase data in a bar chart by one with a button click
- Rendering charts using local Chart.js in overriding Django templates
- Overlay Line on chart.js Graph
- TypeError: Cannot read property 'currentStyle' of null in chart.js
- How to filter chart.js by month
- Calculate weighted sum over all points in chart.js
- How to allow copying of text within Chart.js tooltips?
- HTML in Chart.js labels
- Chart JS data labels getting cut