Javascript 谷歌的X轴图表看起来不太好

Javascript 谷歌的X轴图表看起来不太好,javascript,html,web,google-visualization,pygooglechart,Javascript,Html,Web,Google Visualization,Pygooglechart,我使用GoogleCharts API绘制图表。我得到这个图表: 我在这张图表中的问题是X轴。标签不在里面,看起来不太好。 如果我在X轴上有更多的字符串,它看起来是这样的: 我认为问题是因为X列类型是string而不是DATETIME。 如何更改google图表中的列类型? 或者如何在不更改列类型的情况下更改X轴? 我在下面添加脚本 PHP代码: JS代码: HTML代码: 谢谢 可以强制条形图的x轴设置hAxis.viewWindow.min和hAxis.viewWindow.max:

我使用GoogleCharts API绘制图表。我得到这个图表:

我在这张图表中的问题是X轴。标签不在里面,看起来不太好。 如果我在X轴上有更多的字符串,它看起来是这样的:

我认为问题是因为X列类型是string而不是DATETIME。 如何更改google图表中的列类型? 或者如何在不更改列类型的情况下更改X轴? 我在下面添加脚本

PHP代码:

JS代码:

HTML代码:


谢谢

可以强制条形图的x轴设置hAxis.viewWindow.min和hAxis.viewWindow.max:

这适用于数字或百分比,与日期一起使用有点复杂:在谷歌API中检查,有两种解决方案:

您可以将X主轴更改为离散型和日期型 图表的长轴可以是离散的,也可以是连续的。使用离散轴时,每个系列的数据点根据其行索引在轴上均匀分布。使用连续轴时,数据点将根据其域值进行定位

请阅读以“帮助”开头的链接部分!我的图表不稳定了!其中解释了如何从日期更改为字符串,然后自定义它的步骤。。。
可以强制条形图的x轴设置hAxis.viewWindow.min和hAxis.viewWindow.max:

这适用于数字或百分比,与日期一起使用有点复杂:在谷歌API中检查,有两种解决方案:

您可以将X主轴更改为离散型和日期型 图表的长轴可以是离散的,也可以是连续的。使用离散轴时,每个系列的数据点根据其行索引在轴上均匀分布。使用连续轴时,数据点将根据其域值进行定位

请阅读以“帮助”开头的链接部分!我的图表不稳定了!其中解释了如何从日期更改为字符串,然后自定义它的步骤。。。 我找到了答案

我和大家分享。所以如果有人卡住了,比如我。我们将很快继续提供此帮助

我创建了一个新变量:var showEvery=parseIntdata.getNumberOfRows/4

在选项属性中添加:hAxis:{showTextEvery:showtevery}

因此JS代码如下所示:

    var data = google.visualization.arrayToDataTable(<?php echo $str?>);

    var show = parseInt(data.getNumberOfRows() / 4);

    var options = {
        title: '',
        curveType: 'function',
        legend: { position: 'bottom' },
        width: 1000,
        backgroundColor: '#efeff0',
        is3D: true,
        chartArea: {
        backgroundColor: {
                       stroke: '#efeff1',
                       strokeWidth: 1}},
        hAxis: {showTextEvery: showEvery},
        height: 300
    };

    var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

    chart.draw(data, options);
我找到了答案

我和大家分享。所以如果有人卡住了,比如我。我们将很快继续提供此帮助

我创建了一个新变量:var showEvery=parseIntdata.getNumberOfRows/4

在选项属性中添加:hAxis:{showTextEvery:showtevery}

因此JS代码如下所示:

    var data = google.visualization.arrayToDataTable(<?php echo $str?>);

    var show = parseInt(data.getNumberOfRows() / 4);

    var options = {
        title: '',
        curveType: 'function',
        legend: { position: 'bottom' },
        width: 1000,
        backgroundColor: '#efeff0',
        is3D: true,
        chartArea: {
        backgroundColor: {
                       stroke: '#efeff1',
                       strokeWidth: 1}},
        hAxis: {showTextEvery: showEvery},
        height: 300
    };

    var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

    chart.draw(data, options);

这是最糟糕的。我可以使用API中的一些函数,比如:dataView.setColumns[{calc:functiondata,row{return;},type:'string'},0,1];玩一玩,你会发现你的需求,这与百分比有关,你需要日期…我如何将其更改为日期?它只是得到了最坏的结果。我可以使用API中的一些函数,比如:dataView.setColumns[{calc:functiondata,row{return;},type:'string'},0,1];玩一玩,你会发现你的需求,这与百分比有关,你需要日期…我如何将其更改为日期?
<div id="curve_chart" class="plot" style="width: 50% ; height: 400px ; float:left; margin-left:9%;"></div>
hAxis: {
    viewWindow: {
        min: 0,
        max: 100
    },
    ticks: [0, 50, 100] // display labels every 50
}
    var data = google.visualization.arrayToDataTable(<?php echo $str?>);

    var show = parseInt(data.getNumberOfRows() / 4);

    var options = {
        title: '',
        curveType: 'function',
        legend: { position: 'bottom' },
        width: 1000,
        backgroundColor: '#efeff0',
        is3D: true,
        chartArea: {
        backgroundColor: {
                       stroke: '#efeff1',
                       strokeWidth: 1}},
        hAxis: {showTextEvery: showEvery},
        height: 300
    };

    var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

    chart.draw(data, options);