csekar

Need help with gantt chart XML string

Recommended Posts

Hi I took this example from fusioncharts site.   here is the html file with JSON string. 

But I need it in XML.  I don't know how to convert it.  Please help.  Thank you.

<html>
<head>
<title>My first chart using FusionCharts Suite XT</title>
<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>

<script type="text/javascript">

const dataSource = {
  "chart": {
    "dateformat": "mm/dd/yyyy",
    "caption": "Event Planning Process",
    "theme": "fusion",
    "canvasborderalpha": "40",
    "ganttlinealpha": "50"
  },
  "tasks": {
    "color": "#5D62B5",
    "task": [
      {
        "start": "03/07/2018",
        "end": "03/17/2018"
      },
      {
        "start": "03/14/2018",
        "end": "03/28/2018"
      },
      {
        "start": "03/15/2018",
        "end": "03/31/2018"
      },
      {
        "start": "04/02/2018",
        "end": "04/12/2018"
      },
      {
        "start": "04/12/2018",
        "end": "04/30/2018"
      },
      {
        "start": "04/20/2018",
        "end": "05/06/2018"
      },
      {
        "start": "04/30/2018",
        "end": "05/10/2018"
      },
      {
        "start": "04/30/2018",
        "end": "05/25/2018"
      },
      {
        "start": "05/04/2018",
        "end": "06/05/2018"
      }
    ]
  },
  "processes": {
    "headertext": "Task",
    "headeralign": "left",
    "fontsize": "14",
    "isbold": "0",
    "align": "left",
    "process": [
      {
        "label": "Define event goals"
      },
      {
        "label": "Source venue options"
      },
      {
        "label": "Finalize speaker reach out list"
      },
      {
        "label": "Compose sponsorship strategy"
      },
      {
        "label": "Reach out to sponsors"
      },
      {
        "label": "Create social media campaign"
      },
      {
        "label": "Reach out to blogs for backlinks"
      },
      {
        "label": "Optimize SEO ranking"
      },
      {
        "label": "Publish event lead up vlog series"
      }
    ]
  },
  "categories": [
    {
      "category": [
        {
          "start": "03/05/2018",
          "end": "03/31/2018",
          "label": "March"
        },
        {
          "start": "04/01/2018",
          "end": "04/30/2018",
          "label": "April"
        },
        {
          "start": "05/01/2018",
          "end": "05/31/2018",
          "label": "May"
        },
        {
          "start": "06/01/2018",
          "end": "06/10/2018",
          "label": "June"
        }
      ]
    },
    {
      "category": [
        {
          "start": "03/05/2018",
          "end": "03/11/2018",
          "label": "W 1"
        },
        {
          "start": "03/12/2018",
          "end": "03/18/2018",
          "label": "W 2"
        },
        {
          "start": "03/19/2018",
          "end": "03/25/2018",
          "label": "W 3"
        },
        {
          "start": "03/26/2018",
          "end": "04/01/2018",
          "label": "W 4"
        },
        {
          "start": "04/02/2018",
          "end": "04/08/2018",
          "label": "W 5"
        },
        {
          "start": "04/09/2018",
          "end": "04/15/2018",
          "label": "W 6"
        },
        {
          "start": "04/16/2018",
          "end": "04/22/2018",
          "label": "W 7"
        },
        {
          "start": "04/23/2018",
          "end": "04/29/2018",
          "label": "W 8"
        },
        {
          "start": "04/30/2018",
          "end": "05/06/2018",
          "label": "W 9"
        },
        {
          "start": "05/07/2018",
          "end": "05/13/2018",
          "label": "W 10"
        },
        {
          "start": "05/14/2018",
          "end": "05/20/2018",
          "label": "W 11"
        },
        {
          "start": "05/21/2018",
          "end": "05/27/2018",
          "label": "W 12"
        },
        {
          "start": "05/28/2018",
          "end": "06/03/2018",
          "label": "W 13"
        },
        {
          "start": "06/04/2018",
          "end": "06/10/2018",
          "label": "W 14"
        }
      ]
    }
  ]
};

FusionCharts.ready(function() {
   var myChart = new FusionCharts({
      type: "gantt",
      renderAt: "chart-container",
      width: "600",
      height: "300",
      dataFormat: "json",
      dataSource
   }).render();
});
</script>
</head>
<body>
    <div id="chart-container">FusionCharts XT will load here!</div>
</body>
</html>

 

 

Share this post


Link to post
Share on other sites

Hi,

 

To render the using XML format dtaSource, you need to create the dataSource in the prescribed XML structure of FusionCharts Gantt chart. Please refer to the documentation for the prescribed structure : https://www.fusioncharts.com/dev/chart-guide/standard-charts/gantt-chart

 

You can also use the getXMLData() API method of FusionCharts to fetch the xml dataSource from the rendered chart(using JSON). Sample : http://jsfiddle.net/0nzL2459/

Then use the fetched XML dataSource using the API method in your new chart with "dataFormat" set to "xml". Sample : https://jsfiddle.net/9Low2mkr/

 

getXMLData() API method reference link : https://www.fusioncharts.com/dev/api/fusioncharts/fusioncharts-methods#getxmldata-29

 

Thanks,

Akash.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now