adding decimal places in axis labels

1,809 views
Skip to first unread message

BB

unread,
Sep 13, 2011, 4:38:54 PM9/13/11
to jqplot-users
I'm passing in integers to jqplot and it is rendering axis labels with
a decimal place. I'm doing a very simple line graph. Here's the object
I'm passing in:
{
"axes": {
"yaxis": {
"min": 0
},
"xaxis": {renderer:$.jqplot.DateAxisRenderer}
},
"grid": {
"background": "#ffffff",
"drawGridlines": true,
"shadow": false
},
"series": [
{
"color": "#458CD2",
"pointLabels": {
"show": false
}
}
],
"highlighter": {
"show": true,
"sizeAdjust": 7
},
"cursor": {
"show": false
}
}

Here's the data set I'm passing in:

[[2011-08-28,7060],[2011-08-29,6359],[2011-08-30,3112],
[2011-08-31,2638],[2011-09-01,6254],[2011-09-02,6469],[2011-09-03,0],
[2011-09-04,0],[2011-09-05,0],[2011-09-06,0],[2011-09-07,0],
[2011-09-08,0],[2011-09-09,0],[2011-09-10,0],[2011-09-11,0],
[2011-09-12,6264]]

Any help would be appreciated!

Jake Washbanger

unread,
Sep 13, 2011, 7:05:23 PM9/13/11
to jqplot...@googlegroups.com
I'm not sure what you're looking for.  

Adding/removing decimals places from the axes?

This is the code from the Singlepoint.html code from the examples directory:


<!DOCTYPE html>
<html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Single Negative Point</title> <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]--> <link rel="stylesheet" type="text/css" href="../jquery.jqplot.css" /> <!-- BEGIN: load jquery --> <script language="javascript" type="text/javascript" src="../jquery.js"></script>
  <!-- END: load jquery -->
  
  <!-- BEGIN: load jqplot -->
  <script language="javascript" type="text/javascript" src="../jquery.jqplot.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.canvasAxisTickRenderer.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.cursor.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.highlighter.js"></script>
  <!-- END: load jqplot -->
<script language="javascript" type="text/javascript">
  
$(document).ready(function(){
      $.jqplot.config.enablePlugins = true;
    
    line1 = [-2];
    plot = $.jqplot('chart',[line1],{
    title: 'Rotated Text with Canvas Axis',
      axesDefaults:{tickOptions:{formatString:'%.2f'}},
    axes: {
        xaxis: {
            rendererOptions: {
                tickRenderer: $.jqplot.CanvasAxisTickRenderer
            },
            tickOptions: {
                angle: -40
            }
        }
    },
    series: [{
        markerOptions: {
            size: 12
        }
    }],
    
    cursor:{
        zoom:true,
        tooltipOffset: 10,
        tooltipLocation: 'nw'
    },
    
    highlighter: {
        sizeAdjust: 6
    }
  });
    
});


</script>

  </head>
  <body>
<?php include "nav.inc"; ?>
<div id="chart" style="height:200px; width:300px;"></div>
  </body>
</html>

Chris Leonello

unread,
Sep 13, 2011, 9:50:51 PM9/13/11
to jqplot...@googlegroups.com
Sounds like you need to specify a format string for your axes:

axes: {
  xaxis: {
    tickOptions: {
      formatString: "%d"
    }
  }
}

I enhanced axes to auto compute a good format string based on the tick interval in rev 849.  This isn't in any distribution yet.

-- 
Chris Leonello
http://www.jqplot.com
--
You received this message because you are subscribed to the Google Groups "jqplot-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jqplot-users/-/v43Jof9ke9oJ.
To post to this group, send email to jqplot...@googlegroups.com.
To unsubscribe from this group, send email to jqplot-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jqplot-users?hl=en.

Seggie Fault

unread,
Jun 27, 2017, 10:10:11 PM6/27/17
to jqplot-users
Which commit in Rev 849 does that pertain to please Chris?
Or just a rough section to go poke would also be great.
Looking to pass a minimum length to that...
many thanks

Seggie Fault

unread,
Jun 27, 2017, 10:19:11 PM6/27/17
to jqplot-users
Actually:
 pointLabels: { show: true, location: 'e', edgeTolerance: -15, lables: labelArray, formatString: "%#.2f" },


should meet my needs. Many thanks anyway

Larry Martell

unread,
Jun 30, 2017, 10:16:41 AM6/30/17
to jqplot-users
This is a 6 year old post you are replying to. Chris Leonello seems to
have dropped off the face of the earth. Anyone know what happened to
him?
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jqplot-users...@googlegroups.com.
> To post to this group, send email to jqplot...@googlegroups.com.
> Visit this group at https://groups.google.com/group/jqplot-users.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages