How to remove Intermediate Intervals in Y aixs of Step Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Tue Dec 14, 2010 8:02 am

Hi,
In our application we are using the xy step chart in which currently we are getting some intermediate values in y axis rather than our essential values.

For eg: we are getting the label values like below

10e1,10e2,10e3................10e5 but we need in the way as 10e1,10e2,10e4

Right now we are using the below method for acheiving the above
xAxis.setExpTickLabelsFlag(true);

Is there any other method in jfree to remove the intermediate intervals and define the labels in exponenatial way.Please adivse.

Thanks,
Sat

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Tue Dec 14, 2010 11:29 am

inetmediate values, inetmediate intervals, I couldnt get what you mean by that probably 'cuz of my English?

but have you take a look on the forum?
http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=31605

sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Tue Dec 14, 2010 1:31 pm

Hi,
Thanks For your response.Actually in our implementation we are trying to create a xy axis step chart by using the below values.
double[][] series = new double[][]{
{774.19,580.65,580.65,387.10,387.10,193.55,193.55,0.00,0.00,0.00},
{1,1,12,12,111,111,4642,4642,22358,22358}};
y - axis value -{774.19,580.65,580.65,387.10,387.10,193.55,193.55,0.00,0.00,0.00}
x - axis value -{1,1,12,12,111,111,4642,4642,22358,22358}};
For x -axis we need the values to be plotted between the intervals of 10 power 0,10 power1,10 power 2.But we tried the below method
LogarithmicAxis xAxis = new LogarithmicAxis("Cycles (cumulative)"); which by default taking the x-axis intervals as 1,2,3,4,5,10,20,30,100,150,200

But we need the intervals as mentioned above with power in which we have to plot the graph with the x-axis values.Hope my need is clear for you now.Will you please help me to acheive this.It will be greatful if we get the exact method which will help us to acheive this or a sample code.

Thanks
SAT

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Tue Dec 14, 2010 1:58 pm

"class LogarithmicAxis" doesnt have but if you use "class Logaxis" there is a method:

Code: Select all

xAxis.setBase(10);

sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Tue Dec 14, 2010 2:44 pm

Hi ,
I tried the method form Logaxis which you have specified.But now am not able to veiw any label information in the x-axis.Its plain without any values.Anyother methods which may help?

Thanks
SAT

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Tue Dec 14, 2010 4:02 pm

Image

what do u mean no label information? i see the tick mark labels

sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Tue Dec 14, 2010 6:24 pm

Hi ,
Will you please share me the code for the graph sample with the labels which you have attached?the one which we tried doesnt show the values like 10^1,10^2 as shown in the graph which you have attached.

Thanks
SAT

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Tue Dec 14, 2010 6:56 pm

i didnt do anything than just creating defult everything.

new XYPlot()
new JFreeChart()
new LogAxis()
new NumberAxis()
new XYStepRenderer()
new XYSeries()
new XYSeriesCollection()
new ChartPanel()

thats quite all i ve used, as i said, just the defaults

sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Thu Dec 16, 2010 12:11 pm

Hi,
Thanks for your suggestion.But actually i want my graph to look in this way.

[img]http://en.wikipedia.org/wiki/File:LogLo ... f_Line.GIF[/img]


the x axis value needs to come as how in this sample graph.Will you please suggest me the exact method to achieve the same.

Thanks,
SAT

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by skunk » Thu Dec 16, 2010 3:18 pm

Subscripts and superscripts are not supported without writing some code.

sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Thu Dec 16, 2010 5:52 pm

Hi
It will be helpful if you share me some code for this.

thanks,
SAT

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by skunk » Thu Dec 16, 2010 6:27 pm

The method that actually draws the tick labels is called

Code: Select all

protected AxisState drawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge)
If you look at the supplied source code, you will see that a utility method from org.jfree.text.TextUtilities is used

Code: Select all

TextUtilities.drawRotatedString(tick.getText(), g2, anchorPoint[0], anchorPoint[1], tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor());
You would need to modify the entire call chain so that instances of java.text.AttributedString are used instead of java.lang.String

This would be a non-trivial change, to put it mildly. You might be able to hack together a local override that parsed the string just before it was printed but it would be very brittle.

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Sat Dec 18, 2010 3:10 pm

Code: Select all

public void setMinorTickMarksVisible(boolean flag)
???

what is sathu77 is asking and what skunk is trying to solve, i dont get. is it log axis on both axes we are talking about or what?

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by skunk » Sat Dec 18, 2010 4:49 pm

I thought he was asking how to display 10¹ ... 10² ... 10³ instead of 10^1 ... 10^2 ... 10^3 as that was the only difference between the axis you displayed and the one he linked to

sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Sun Dec 19, 2010 5:37 pm

Hi ,
Exactly as you said we need to display 10¹ ... 10² ... 10³ instead of 10^1 ... 10^2 ... 10^3.

The below is the way we tried to obtain the same but failed.Will anybody guide to acheive that

Code: Select all

 //BELOW CODE TO CREATE CHART.
  
  JFreeChart chart = ChartFactory.createXYLineChart(
    null,
    "Range Values ",
    "",
    dataset, //CREATED DATA SET EARLIER AND PASSING HERE.
    PlotOrientation.HORIZONTAL,
    true,
    true,
    false
  );


  // CREATED ATTRIBUTE
  
  for(curVal=0;curVal<7;curVal++){
   String strVal=10+""+curVal;
   as = new AttributedString(strVal);
   as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, 2, 3);
  }
  AttributedCharacterIterator attrItr=as.getIterator();
  Map<Attribute, Object> mapAttrKeys= attrItr.getAttributes();
  for (Map.Entry<Attribute,Object> entry : mapAttrKeys.entrySet()) {
   Attribute  attrKey = (Attribute  )entry.getKey();
   Object attrValue= entry.getValue();
   System.out.println("Attribute Key L:--> "+attrKey+" Attribute Value :--> "+attrValue.toString());
  }
  ghs.drawString(as.getIterator(), 30+curVal*20, 50+curVal*5);
  
  
  // BELOW CODE FOR SETTING THE LABLES FOR X AXIS.
  
  LogAxis xAxis = new LogAxis("");
    xAxis.setLowerBound(1);
    xAxis.setUpperBound(1000000);
    xAxis.setTickLabelsVisible(true);
    xAxis.setTickLabelInsets(RectangleInsets.ZERO_INSETS);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.BOLD, 10));
  plot.setRangeAxis(xAxis);
If i try to create the superscript also it only done through the paint(),which paint and clears.
And one more thing is in our applicationo we are generating simulataneously stepchart,curve chart for the same x,y values.What ever changes we are doing should no be like supporting only step or curve or line but all.Please advise.

Thanks,
SAT

Locked