最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AmChart is not working in safari - Stack Overflow

programmeradmin7浏览0评论

I have json object which i pass to AmCharts.makeChart() function as a data provider and it shows proper graph in firefox, chrome and ie but not in safari

I also see that json data in console but still graph not es

I had used amchart.js, serial.js

Thanks in advance...

I have json object which i pass to AmCharts.makeChart() function as a data provider and it shows proper graph in firefox, chrome and ie but not in safari

I also see that json data in console but still graph not es

I had used amchart.js, serial.js

Thanks in advance...

Share Improve this question edited Nov 4, 2014 at 7:00 Gilsha 14.6k3 gold badges36 silver badges48 bronze badges asked Nov 4, 2014 at 6:27 Kishan UpadhyayKishan Upadhyay 661 silver badge6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

I had the same problem. Passing "dataDateFormat": "YYYY-MM-DD HH:NN:SS" to the AmCharts.makeChart mand solved the issue for me. An example graph code would look like this:

var chart1 = AmCharts.makeChart("chartdiv1", {
    "type": "serial",
    "theme": "dark",
    "pathToImages": "amcharts/images/",
    "dataProvider": chartData,
    "valueAxes": [{
        "position": "left",
        "title": "temperature (\xB0C)"
    }],
    "graphs": [{
        "fillAlphas": 0.4,
        "valueField": "temp"
    }],
    "chartScrollbar": {},
    "chartCursor": {
        "categoryBalloonDateFormat": "JJ:NN, DD MMMM",
        "cursorPosition": "mouse"
    },
    "categoryField": "time",
    "categoryAxis": {
        "minPeriod": "mm",
        "parseDates": true,
        "title": "date"
    },
    "dataDateFormat": "YYYY-MM-DD HH:NN:SS"
});

In my case, the JSON object was created from a mysql database from a php script. The database contained epoch timestamps which I converted into date time format in mysql by using a FROM_UNIXTIME(time) select query. This gives me dates like 2014-10-06 22:04:16. Apparently, Chrome and firefox can handle such date strings natively but safari cannot.

This is a Safari specific issue.

Adding dataDateFormat: YYYY-MM-DD HH:NN:SS to AmCharts.makeChart solved the issue as answered by Thawn here:

https://stackoverflow./a/26795224/4448807

发布评论

评论列表(0)

  1. 暂无评论