From service method you need to return an object[] of your type..For your req create class with three properties 2 of type string and one integer and return array via service method
~ Remember To Mark The Post(s) That Helped You As The ANSWER ~
Shakti Singh Tanwar
.Net Trainer (MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
manishprajap...
Contributor
3168 Points
657 Posts
Need to generate dynamic data in DD chart.
Jun 06, 2011 04:44 AM|LINK
I am using DD_Chart for a graph. and I am using following code:-
<script type="text/javascript"> $(function() { $("#chart_div_jqui").ddBarChart({ chartData: { "COLUMNS":["X_BAR_LABEL","X_BAR_VALUE","TOOL_TIP_TITLE"], "DATA":[ ["Tom",1238,"Tom ^ "], ["Dick",1069,"Dick ^ "], ["Harry",1214,"Harry ^ "], ["Mary",1262,"Mary ^ "], ["Louise",1975,"Louise ^ "], ["Sue",1076,"Sue ^ "] ] }, chartContext: "Sales", xOddClass: "ui-state-active", xEvenClass: "ui-state-default", yOddClass: "ui-state-active", yEvenClass: "ui-state-default", xWrapperClass: "ui-widget-content", chartWrapperClass: "ui-widget-content", chartBarClass: "ui-state-focus ui-corner-top", chartBarHoverClass: "ui-state-highlight", tooltipSettings: {extraClass: "ui-widget ui-widget-content ui-corner-all"} }); }); </script> <div id="chart_main_div" style="position:relative; width:100%; height:100%"> </div>Now I need to generate this block using webservice or string variable or json object :-
Thanks,
Manish Prajapati
Shakti Singh...
Star
10870 Points
1827 Posts
Re: Need to generate dynamic data in DD chart.
Jun 06, 2011 05:41 AM|LINK
Create a JSON enabled WCF Service and call from code
http://dotnetslackers.com/articles/ajax/JSON-EnabledWCFServicesInASPNET35.aspx
From service method you need to return an object[] of your type..For your req create class with three properties 2 of type string and one integer and return array via service method
Shakti Singh Tanwar
.Net Trainer (MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
manishprajap...
Contributor
3168 Points
657 Posts
Re: Need to generate dynamic data in DD chart.
Jun 06, 2011 11:20 AM|LINK
Actually i am storing the value in text box:-
<input type="text" value='"Tom"~1238~"Tom ^ "|"Dick"~1069~"Dick ^ "' id="Jsondata" />
and try to do like this but did not get any success yet
var data = document.getElementById("Jsondata").value.split('|'); var jsonObj = []; //declare array for (var i = 0; i < data.length; i++) { var value = data[i].split('~'); jsonObj.push([value[0], value[1], value[2]]); } alert(jsonObj); $("#chart_div_jqui").ddBarChart({ chartData: { "COLUMNS": ["X_BAR_LABEL", "X_BAR_VALUE", "TOOL_TIP_TITLE"], "DATA": jsonObj }, chartContext: "Sales", xOddClass: "ui-state-active", xEvenClass: "ui-state-default", yOddClass: "ui-state-active", yEvenClass: "ui-state-default", xWrapperClass: "ui-widget-content", chartWrapperClass: "ui-widget-content", chartBarClass: "ui-state-focus ui-corner-top", chartBarHoverClass: "ui-state-highlight", tooltipSettings: { extraClass: "ui-widget ui-widget-content ui-corner-all" } });The object should like this:-
[
["Tom", 1238, "Tom ^ "],
["Dick", 1069, "Dick ^ "]
]
Thanks,
Manish Prajapati
manishprajap...
Contributor
3168 Points
657 Posts
Re: Need to generate dynamic data in DD chart.
Jun 06, 2011 11:25 AM|LINK
I have resoved my issue:-
var data = document.getElementById("Jsondata").value.split('|');
var jsonObj = []; //declare array
for (var i = 0; i < data.length; i++) {
var value = data[i].split('~');
jsonObj.push([value[0], parseInt(value[1]), value[2]]);
}
alert(jsonObj);
$("#chart_div_jqui").ddBarChart({
chartData: {
"COLUMNS": ["X_BAR_LABEL", "X_BAR_VALUE", "TOOL_TIP_TITLE"],
"DATA": jsonObj
},
chartContext: "Sales",
xOddClass: "ui-state-active",
xEvenClass: "ui-state-default",
yOddClass: "ui-state-active",
yEvenClass: "ui-state-default",
xWrapperClass: "ui-widget-content",
chartWrapperClass: "ui-widget-content",
chartBarClass: "ui-state-focus ui-corner-top",
chartBarHoverClass: "ui-state-highlight",
tooltipSettings: { extraClass: "ui-widget ui-widget-content ui-corner-all" }
});
Thanks,
Manish Prajapati
sraavsarma
Member
2 Points
1 Post
Re: Need to generate dynamic data in DD chart.
Dec 24, 2012 05:40 AM|LINK
Hi..this is sravan.I am unable to get the ddcharts output even though i kept all .js files and .css files. pls resolve it need ful