To create piechart in highcharts

Below is my JSON format of data from which I want to create a pie chart in highcharts..

{
  "title": {"text": "Pie"},

  "series": 
  [
    {
        "type": "pie",
        "name": "Actual",
        "data": 
         [
            [
                "Salesgrowth",
                45
            ],
            [
                "marketshare",
                26.8
            ]
         ]
    }
  ]
}

This is valid JSON , I am getting this output from Web Service, when I call this service and evoke this method to run this JSON output to create pie then I get the error as follows,

Uncaught TypeError: Cannot set property 'renderTo' of undefined 

Below is the JQuery function that I make use to call my file where I stored this JSON output from my web service,

function loadJson() {
       $(document).ready(function () {
           //alert("inside");
           var chart;
           var seriesData;
           $.getJSON("val1.json", function (data) {
               var chartoptions = data;
               chartoptions.chart.renderTo = 'container';
               chart = new Highcharts.Chart(chartoptions);

           });

       });
   },

and this function runs well with other kind of charts like bar graph,line graph and column graph...tested with all kinds of graphs, I am facing problem only with pie chart...any help will be greatly appreciated

---------Updated question------ Below is my JSON output I have changed in order to get values

{
   "title":{"text":"Financial"},
   "chart":{"type":"pie"},
   "series":
     [ {"name":"Actual-Market Share","data":["Market Share",30]},{"name":"Actual-Market Share","data":["Sales Growth",70]}]}

and below is the output I am getting,

I am not able to identify what I am exactly messing with...Any idea will be of great help...

----------Updated output-----------

  {
    "legend":{"enabled":"true"},
    "title":{"text":"Financial"}, 
    "chart":{"type":"pie"},
    "series":[{"name":"Actual","data":[{"str":"Market Share","flo":20}]},
              {"name":"Actual","data":[{"str":"Sales Growth","flo":30}]},
              {"name":"Actual","data":[{"str":"Operating Profit","flo":40}]},
              {"name":"Actual","data":[{"str":"Gross Margin %","flo":10}]}]}

Answers


Your json doesn't include a chart object, so setting chart.renderTo won't work.

If you can change the webservice, get it to add the following to your json:

 chart: {
    },

If you can't change the back end, you can change your javascript to add the chart object before setting renderTo:

$.getJSON("val1.json", function (data) {
           var chartoptions = data;
           if (typeof chartoptions.chart === 'undefined')  {
               chartoptions.chart = {};
           }
           chartoptions.chart.renderTo = 'container';
           chart = new Highcharts.Chart(chartoptions);
       });

Need Your Help

Dynamics AX 2009 - Duplicate IDs

object axapta

We are in the process of merging projects from different AX Servers into source control on the same AX server. However, a few object IDs are common between projects, so Dynamics throws an error when

Seeing the source code instead of a website

c# asp.net mono mamp

I'm kind of new in ASP.NET and C# so it may sound a stupid question.