Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8805589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:54:19+00:00 2026-06-14T01:54:19+00:00

I have this json which i need to work with amCharts line chart, var

  • 0

I have this json which i need to work with amCharts line chart,

        var chartData = [{
            date: "2009/10/2",
            value: 5,
            name: 5
        }, {
            date: "2009/10/3",
            value: 15,
            name: 5

        }, {
            date: "2009/10/4",
            value: 13,
            name: 10
        }, {
            date: "2009/10/5",
            value: 17,
            name: 30
        }, {
            date: "2009/10/6",
            value: 15,
            name: 5
        }, {
            date: "2009/10/7",
            value: 19,
            name: 5
        }];

in order to be compatible with amCharts i need to assign date value as a Date object so i did through the following function,

        function parseDate(){

            for( var i = 0; i < chartData.length; ++i ) {
                var dateArray = chartData[i]["date"].split("/");

                chartData[i]["date"] =  new Date(Number(dateArray[0]), Number(dateArray[1])-1, Number(dateArray[2]));
                window.alert(chartData[i]["date"]);//for debugging purposes
            }
            return chartData;
        }

But still i get an empty graph with no lines.. 🙁 but if i hard code the json as follows,

        var chartData = [{
            date: new Date(2009, 10, 2),
            value: 5,
            name: 5
        }, {
            date: new Date(2009, 10, 3),
            value: 15,
            name: 5

        }, {
            date: new Date(2009, 10, 4),
            value: 13,
            name: 10
        }, {
            date: new Date(2009, 10, 5),
            value: 17,
            name: 30
        }, {
            date: new Date(2009, 10, 6),
            value: 15,
            name: 5
        }, {
            date: new Date(2009, 10, 7),
            value: 19,
            name: 5
        }];

The chart is displayed ,Please help me on this one.

Thank you very much 🙂

EDIT: CODE TO GENERATE GRAPH (FYI)

        AmCharts.ready(function () {

            parseDate();

            // SERIAL CHART    
            chart = new AmCharts.AmSerialChart();
            chart.pathToImages = "../amcharts/images/";
            chart.zoomOutButton = {
                backgroundColor: '#000000',
                backgroundAlpha: 0.15
            };
            chart.dataProvider = chartData;
            chart.categoryField = "date";

            // listen for "dataUpdated" event (fired when chart is inited) and call zoomChart method when it happens
            chart.addListener("dataUpdated", zoomChart);

            // AXES
            // category                
            var categoryAxis = chart.categoryAxis;
            categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
            categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
            categoryAxis.dashLength = 2;
            categoryAxis.gridAlpha = 0.15;
            categoryAxis.axisColor = "#DADADA";


            var i = 0;
            for (var key in chartData[0]) {
                if (key != 'date') {
                    var valueAxis = new AmCharts.ValueAxis();
                    valueAxis.offset = i * 40;
                    valueAxis.dashLength = 4;
                    valueAxis.axisColor = "#FF6600";
                    valueAxis.axisAlpha = 0;
                    chart.addValueAxis(valueAxis);

                    // GRAPH
                    var graph = new AmCharts.AmGraph();
                    graph.valueAxis = valueAxis; // we have to indicate which value axis should be used
                    graph.type = "line";
                    graph.title = "infection # " + i;
                    graph.valueField = key;

                    graph.customBullet = "images/star.gif"; // bullet for all data points
                    graph.bulletSize = 14; // bullet image should be a rectangle (width = height)
                    graph.customBulletField = "customBullet"; // this will make the graph to display custom bullet (red star)
                    chart.addGraph(graph);
                }
                i = i + 1;
            }


            // CURSOR
            var chartCursor = new AmCharts.ChartCursor();
            chartCursor.cursorPosition = "mouse";
            chart.addChartCursor(chartCursor);

            // SCROLLBAR
            var chartScrollbar = new AmCharts.ChartScrollbar();
            chart.addChartScrollbar(chartScrollbar);

            // LEGEND
            var legend = new AmCharts.AmLegend();
            legend.marginLeft = 110;
            chart.addLegend(legend);

            // WRITE
            chart.write("chartdiv");
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:54:21+00:00Added an answer on June 14, 2026 at 1:54 am

    Try this:

    function parseDate() {
      for( var i = 0; i < chartData.length; ++i )
        chartData[i]["date"] =  new Date(chartData[i]["date"]);
      return chartData;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JSON (which validates according to JSONLint ): [ { "BugCount":"2", "BugTitle":"C:\\INETPUB\\WWWROOT\\CLUBREADY2\\TRAINERS\\../Connections/LTC.asp",
I have this json which populates my collection ( TableListCollection ) of models (
I have a JSON file which contains a pound symbol in it. This json
I have a JSON which looks like this { secInfo: [ { loginResult: 1,
I have a JSON which I get from web application. I try this parse
I have a json feed from this URL which contains 20 fields and I
I am getting JSON string from website. I have data which looks like this
I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it
i have one jquery function which i need to work in following way 1.
i have this JSON object: {error:null, result:[{id:1234567890, count:1, recipients: [u3848, u8958, u7477474 ], dateCreated:2012-06-13T09:13:45.989Z

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.