Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i wnat to pass the values of slice to the controller in mvc.i have the value in the var id. Now i want to pass that value to my controller.Below is my code to generate the pie chart
C#
<script>

       var width = 960,
           height = 500,
           radius = Math.min(width, height) / 2;

       var color = d3.scale.ordinal()
           .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);

       var arc = d3.svg.arc()
           .outerRadius(radius - 10)
           .innerRadius(0);

       var pie = d3.layout.pie()
           .sort(null)
           .value(function (d) { return d.population; });

       var svg = d3.select("body").append("svg")
           .attr("width", width)
           .attr("height", height)
         .append("g")
           .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

       d3.csv("/temp/data.csv", function (error, data) {

           data.forEach(function (d) {
               d.population = +d.population;
           });

           var g = svg.selectAll(".arc")
               .data(pie(data))
             .enter().append("g")
               .attr("class", "arc");

           g.append("path")
               .attr("d", arc)
               .style("fill", function (d) {
                  return color(d.data.age);})
                .on('click', function (d) {
                    var id = d.data.age;

                });

           g.append("text")
               .attr("transform", function (d) { return "translate(" + arc.centroid(d) + ")"; })
               .attr("dy", ".35em")
               .style("text-anchor", "middle")
               .text(function (d) { return d.data.age; })

       });
   </script>
Posted
Comments
Nathan Minier 19-Dec-14 9:46am    
Are you using Vanilla JavaScript, jQuery, or other?

Also, what value do you intend to pass?

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