Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I insert a d3 animation using the razor view engine? I have a layout and a render body section:

It uses d3 to create an SVG object on the 'body' but this does not render correctly in the body section of the page?????????


<body>


@RenderBody() //I would suspect the animation would be placed here?



© @DateTime.Now.Year - My ASP.NET Application





@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>

I then have a page that uses a javascript file to run an animation:


XML
@{
    ViewBag.Title = "InsertionSort";
}

<head>
    <meta charset="UTF-8">
    <title>D3 insertion sort</title>
    <link href="~/Content/AlgorithmStyles/insertioSort.css" rel="stylesheet" />
</head>
<body>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script src="~/Algorithms/Sorting/insertionsort.js"></script>
    <h2>My Test</h2>
    <h1></h1>
</body>




ar svg = d3.select('body')
.append('svg')
.attr('width', width)
.attr('height', height);

svg.selectAll('rect')
.data(dataset)
.enter()
.append('rect')
.attr('x', function (d, i) { return x(i); })
.attr('y', function (d) { return height - y(d); })
.attr('width', x.rangeBand())
.attr('height', function (d) { return y(d); })
.call(drag);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900