X轴上的Google图表值未正确显示

时间:2013-04-10 20:09:28

标签: javascript google-visualization

我有两个图表,它们是用javascript以相同的方式创建的,其中一个正确显示x轴上的值,另一个没有。

所以这是交通图表 enter image description here

如您所见,日期在x轴下正确显示,以下是生成此图表的代码

function drawTrafficChart(processedData, humanReadableName, params) {
    dataArray = [];
    dataArrayRow = ['Date', 'Impressions', 'Detail Page Views'];
    dataArray.push(dataArrayRow);
    for (i in processedData) {
        dateString = processedData[i].date;
        dateString = formatDateStringAccordingToAggregationType(dateString, params);
        dataArrayRow = [dateString, processedData[i].event1, processedData[i].event2];
        dataArray.push(dataArrayRow);
    }

    var dataTable = google.visualization.arrayToDataTable(dataArray);
    var chartOptions = {
        title: 'Traffic Chart',
        hAxis: {title: humanReadableName},
        vAxis: {minValuex: 0},
        pointSize: 5,
        width: 670,
        height: 300
    };
    var chart = new google.visualization.LineChart(document.getElementById('traffic_chart'));
    chart.draw(dataTable, chartOptions);
}

这是点击图表 enter image description here

以下是生成点击图表的代码

function drawClickChart(processedData, humanReadableName, params) {
    dataArray = [];
    dataArrayRow = ['Date', 'Website Clicks', 'Image Clicks', 'Video Clicks'];
    dataArray.push(dataArrayRow);
    for (i in processedData) {
        dateString = processedData[i].date;
        dateString = formatDateStringAccordingToAggregationType(dateString, params);
        dataArrayRow = [dateString, processedData[i].event3, processedData[i].event4, processedData[i].event5];
        dataArray.push(dataArrayRow);
    }

    var dataTable = google.visualization.arrayToDataTable(dataArray);
    var chartOptions = {
        title: 'Click Chart',
        hAxis: {title: humanReadableName},
        vAxis: {minValuex: 0},
        pointSize: 5,
        width: 670,
        height: 300
    };
    var chart = new google.visualization.LineChart(document.getElementById('click_chart'));
    chart.draw(dataTable, chartOptions);
}

正如你可以看到x轴上的日期搞砸了,我有什么办法可以解决这个问题吗?

0 个答案:

没有答案