Jump to content
Software FX Community

How to get labels in centre?


anamika

Recommended Posts

I have a 3D Gantt chart. On Y axis labels appear exactly on tick marks. How can I get them in centre i.e. in between two tick marks?

 

I have following code and chart:

 axisY.setMin(minAxisY);

 axisY.setMax(maxAxisY);

 axisY.setStep(stepAxisY);

 

  axisY.setGridlines(true);

  axisY.getGrid().setColor(Color.GREY);

  axisY.setTickMark(TickMark.INSIDE);

  axisY.getLine().setColor(Color.GREY);

  axisY.setTextColor(Color.GREY);

  axisY.setFont(new Font("Arial", Font.PLAIN, 8));

 

  chart.getAxisX().getLine().setColor(Color.GREY));

  chart.getAxisX().setVisible(false);

 

  chart.setBackColor(Color.WHITE);

  chart.setBorder(false);

  chart.setScheme(Scheme.SOLID);

  chart.setGallery(Gallery.GANTT);

  chart.setChart3D(false);

  chart.setRightGap(10);

  chart.setLeftGap(10);

  chart.setTopGap(10);

  chart.setBottomGap(10);

  chart.setBorderObject(new DefaultBorder(BorderType.NONE));

 

Posted Image

 

 

 

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Roughly,

  Set your current major gridlines as minor gridlines with a spacing of n/2 where n is the interval currently being displayed. Make their color and tick mark both the same color as your plotting area background. This will hide them but still render the minor axis labels. Then turn on your minor axes and set them to the color that is currently displayed. No labels are requied on these new minors.

 

Good luck. 

Link to comment
Share on other sites

There is an easier way: 

There is a flag ins the AxisStyle (AxisStyle.Centered) that will do just that. I don't know exactly what the JAVA code will be but it must be something like:

chart.getAxisY().setStyle(chart.getAxisY().getStyle() | AxisStyle.Centered);

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...