admin管理员组文章数量:1419168
Below is part of a script based on the jqplot bar plot examples. I am trying to rotate the x axis tick lables as they are overlapping I have imported the TickRender plugin, however when I add the following code to the script below the graph fails to print at all.
Can you tell how I can do this correctly.
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -30,
fontSize: '10pt'
}
//jqplot script
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
var s1 = [2314,2053,94,70,2541,2626,2551,2515,2147,116,82,2536,2560,2558,2465,2127,103,73,2546,2554,2583,2527,2235,104,88,2515,2604,2641,2532,2142];
var ticks = ['01/11/2012','02/11/2012','03/11/2012','04/11/2012','05/11/2012','06/11/2012','07/11/2012','08/11/2012','09/11/2012','10/11/2012','11/11/2012','12/11/2012','13/11/2012','14/11/2012','15/11/2012','16/11/2012','17/11/2012','18/11/2012','19/11/2012','20/11/2012','21/11/2012','22/11/2012','23/11/2012','24/11/2012','25/11/2012','26/11/2012','27/11/2012','28/11/2012','29/11/2012','30/11/2012'];
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
pointLabels: { show: true }
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -30,
fontSize: '10pt'
}
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});
$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
}
);
});
Below is part of a script based on the jqplot bar plot examples. I am trying to rotate the x axis tick lables as they are overlapping I have imported the TickRender plugin, however when I add the following code to the script below the graph fails to print at all.
Can you tell how I can do this correctly.
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -30,
fontSize: '10pt'
}
//jqplot script
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
var s1 = [2314,2053,94,70,2541,2626,2551,2515,2147,116,82,2536,2560,2558,2465,2127,103,73,2546,2554,2583,2527,2235,104,88,2515,2604,2641,2532,2142];
var ticks = ['01/11/2012','02/11/2012','03/11/2012','04/11/2012','05/11/2012','06/11/2012','07/11/2012','08/11/2012','09/11/2012','10/11/2012','11/11/2012','12/11/2012','13/11/2012','14/11/2012','15/11/2012','16/11/2012','17/11/2012','18/11/2012','19/11/2012','20/11/2012','21/11/2012','22/11/2012','23/11/2012','24/11/2012','25/11/2012','26/11/2012','27/11/2012','28/11/2012','29/11/2012','30/11/2012'];
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
pointLabels: { show: true }
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -30,
fontSize: '10pt'
}
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});
$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
}
);
});
Share
Improve this question
edited Jan 15, 2013 at 14:29
Mark
109k20 gold badges179 silver badges236 bronze badges
asked Jan 15, 2013 at 13:34
George ThompsonGeorge Thompson
7,0674 gold badges18 silver badges16 bronze badges
2 Answers
Reset to default 4Try this,
axesDefaults: {
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -90,
fontSize: '10pt'
}
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
},
}
OR
axes: {
xaxis: {
renderer:$.jqplot.DateAxisRenderer,
ticks: ticks,
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -90,
fontSize: '10pt'
}
}
}
OR
axes: {
xaxis: {
renderer:$.jqplot.DateAxisRenderer,
ticks: ticks,
rendererOptions:{
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -90,
fontSize: '10pt'
}
}
}
}
Include the below files from http://www.jqplot./examples/rotated-tick-labels.php
<script class="include" type="text/javascript" src="js/jquery.jqplot.chartCode.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.dateAxisRenderer.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.canvasTextRenderer.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.canvasAxisTickRenderer.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.categoryAxisRenderer.js"></script>
<script class="include" type="text/javascript" src="js/plugins/jqplot.pointLabels.js"></script>
<script class="include" type="text/javascript" src="js/plugins/jqplot.barRenderer.js"></script>
<script class="include" type="text/javascript" src="js/plugins/jqplot.pieRenderer.js"></script>
本文标签: javascriptHow can I rotate the x axis label in this jqplot scriptStack Overflow
版权声明:本文标题:javascript - How can I rotate the x axis label in this jqplot script - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745305924a2652643.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论