首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQplot formatString "%n“

jQplot formatString "%n“
EN

Stack Overflow用户
提问于 2014-09-30 15:22:43
回答 1查看 2.2K关注 0票数 1

我对jQplot有点小问题。我正在尝试这样做一个DateAxisRenderer:http://tinyurl.com/p8v5coh

我有这个:http://tinyurl.com/qd2lbxh

我不想在我的测试中轮换。我只想在我的小时和日期之间输入一个换行符。

下面是我的代码:

代码语言:javascript
复制
var plot1 = $.jqplot('chart1', [test2], {
        title:'Plot to test JQPLOT',
        legend: {
            show: true,
            placement: 'outsideGrid'
        }, 

    axesDefaults: {
        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
        tickOptions: {
            angle: 0,
            fontSize: '10pt'
        }
    },      


    axes: {
        xaxis: {
            label: "X Axis",
            renderer:$.jqplot.DateAxisRenderer, 
            tickOptions: {
                formatString: '%H %#.2f %n %#.2f %#d-%#m-%Y',
            },
            //min:'June 16, 2008 8:00AM', 
            tickInterval:'14400000',
        },
        yaxis: {
            label: "Y Axis",
            renderer: $.jqplot.LogAxisRenderer,  
            tickOptions: {
                angle: 0
            }
        }
    },
    highlighter: {
        show: true,
        sizeAdjust: 20,
    },
    cursor:{
        show: true,
        zoom: true,
        showTooltip:false
    },
    series:[{showMarker:false}],
});

如你所见,我已经尝试了'%n‘,因为它是在官方文档中写入的。我认为这是愚蠢的,但我不能自己解决这个问题。换行符不起作用。

你能告诉我正确的路吗?

Ty

jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html

EN

回答 1

Stack Overflow用户

发布于 2014-09-30 20:49:35

jqplot有时会用轴和标签做一些奇怪的事情。这就是为什么我通常像这样手动定义我自己的轴刻度:

代码语言:javascript
复制
axes: {
            xaxis: {
                tickRenderer: $.jqplot.CanvasAxisTickRenderer,
                labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                label: 'Date',
                tickOptions:{formatString:'%b %Y'},
                pad: 0,
                ticks: lsTicks,
                renderer: $.jqplot.DateAxisRenderer
            },

其中lsTicks看起来像这样:

代码语言:javascript
复制
["2014-01", "2014-02", "2014-03", "2014-04"]

并且它的长度与您的数据相同。为了让事情更具可读性,你可以添加tickOptions: {angle: -20},,这样如果你有太多的日期放在一起,你的日期就会以一定的角度出现。

tickOptions:{formatString:'%b %Y'}说:显示一个3个字母的月份,然后显示一个4位数字的年份。有关更多选项和信息,请参阅here

或者,您可以使用minmaxtickInterval,但我发现它们有时表现不佳。有关详细信息,请参阅herehere

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26115004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档