I am trying to provide charts once in a partial view in my ASP.NET mvc application. When I put the code in html
and placed it in my project (not in any view or any folder, just in the root folder) and to run html in the browser, everything works fine As I have inserted the HTML code in a partial view and tried to render it, it does not render. The following is my code
& lt; Script type = "text / javascript" src = "~ / scripts / jquery-1.11.2.js" & gt; & Lt; / Script & gt; & Lt; Style & gt; .bar {fill: steelblue; } .bar: hover {fill: brown; } .xx {font: 10px without-serif; }. Axis Path, .xx {fill: none; Stroke: # 000; Shape Rendering: Crisp Edges; }. X Axis Path {Display: None; } & Lt; / Style & gt; & Lt; Body & gt; & Lt; Script src = "~ / scripts / d3.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Var margin = {top: 20, right: 20, bottom: 30, on the left: 40}, width = 960 - margin. Left - margin. Right, height = 500 - margin.Top - margin.bottom; Var x = d3.scale.ordinal () .rangeRoundBands ([0, width], .1); Var y = d3.scale.linear () .ange ([height, 0]); Var xAxis = d3.svg.axis () .scale (x) .orient ("bottom"); Var yAxis = d3.svg.axis () .scale (y) .orient ("left"). Ticks (10, "%"); Var svg = d3.select ("body"). Attached ("svg") .attr ("width", width + margin.left + margin.right) .attr ("height", height + margin.top + margin below). Append ("g") .attr ("conversion", "translation (" + margin. Left + "," + margin.Top + ")"); $ Ajax ({url: 'http: //localhost/ABCD.Portal/Dashboard/GetData', type: 'GET', data: '', cache: incorrect, datatype: 'text', async: true, error: work (Xhr) {// warning ('error:' + xhr.statusText);}, success: work (results) {result = eval (JSON.parse (results); warning (result); x.domain (result. Map (function (d) {return d.letter;}); y.domain ([0, d3.max (result, function (d) {return d.freecency;})); svg.append ("g" ) .attr ("class", "x axis") .attr ("transform", "translate (0," + height + ")") .class (xAxis); svg.append ("g") atr (" Class "," Y axis ") .color (yAxis) .append (" text ") .attr (" conversion "," twisting Style ("text-anchor", "end") .text ("Frequency"); ( "Bar") .attr ("class", "bar") .attr ("x", function (d) {return x} (d.letter);}) .attr ("width", x.rangeBand () ) .attr ("y", function (d) {return y (d.frequency);}) .attr ("height", function (d) {return height - y (defrequency);});}}); Function type (d) {d.frequency = + d.frequency; Return D; } & Lt; / Script & gt; & Lt; / Body & gt;
plus I also keep the warning
Synchronous XMLHttpRequest terminated on the main thread is deprecated due to its harmful effects to user experience. For more help, see http://xhr.spec.whatwg.org/.
Please help.
No comments:
Post a Comment