Minor and major ticks with DateAxis/ValueAxis 2 create a ECG

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
gizza
Posts: 7
Joined: Tue Oct 14, 2008 8:25 am

Minor and major ticks with DateAxis/ValueAxis 2 create a ECG

Post by gizza » Tue Oct 14, 2008 8:40 am

Hi everyone,

I am implementing an ECG chart using the XYPlot with a DateAxis. I would like to have a chart grad range of 200ms as it the 'standard' for ECG charts, so I set up the following code with setting the tick range:

Code: Select all

DateAxis timeAxis (DateAxis) plot.getDomainAxis();
timeAxis.setTickUnit(new DateTickUnit(DateTickUnit.MILLISECOND, 200));
timeAxis.setDateFormateOverride(new SimpleDateFormate("mm:ss"));
The chart has a grid/tick range of 200ms which I would like to have, sweet! My problem now is that the axis labeling is done as well every 200ms, therefore I cannot read the axis labeling cos it is overlapping.

Is there a way to have a grid of 200ms but a axis labeling that is only every second?


This might be already discussed in the forum I just did not know how I should formulate my question.

:arrow: Thank you for your help!

Chris
Last edited by gizza on Wed Oct 15, 2008 2:03 am, edited 1 time in total.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Post by paradoxoff » Tue Oct 14, 2008 7:54 pm

Hi,
what you want are "minor ticks". At present, DateAxis and NumberAxis only support major ticks for which you will get a tick mark, a grid line and a tick label (unless you hide them).
You may find minor tick support for all ValueAxis subclasses in the next release. Then you will still get grid lines and tick marks for minor ticks but no tick label.
If you need this feature now you could patch your local JFreeChart version.

gizza
Posts: 7
Joined: Tue Oct 14, 2008 8:25 am

Minor and major tick with DateAxis and ValueAxis for ECG/EKG

Post by gizza » Wed Oct 15, 2008 2:01 am

Thx @ paradoxoff for the fast reply!

About hiding ticks:
if i hide a tick this will result in a hidden 'tick label' but also the grid line referring to the tick will be hidden?

About patching:

Do you mean by patching using a developer version?

Other possiblities?
Do you know another 'framework' by heart that support the feature I need (cf. drawing below)? As this new feature will only be available for ValueAxis which does not help me as I am using DateAxis. Is there a workaround?

Code: Select all

           'minor tick mark'
                 |
                 V
  200ms          
|--------|-------|-------|-------|-------|-------|---- ....... 
|                                                |                               
0sec                                            1sec  <--- 'tick label'

                                                 ^
                                                 |
                                           'major tick mark'
                           
:arrow: thanks for your answers! :arrow:

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Oct 15, 2008 8:21 am

paradoxoff wrote:You may find minor tick support for all ValueAxis subclasses in the next release. Then you will still get grid lines and tick marks for minor ticks but no tick label.
Yes, this feature is in Subversion and will be included in the 1.0.12 release (which will probably be next month).

[To 'gizza', note that DateAxis is a subclass of ValueAxis, so it will inherit the feature too].
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

gizza
Posts: 7
Joined: Tue Oct 14, 2008 8:25 am

Post by gizza » Wed Oct 15, 2008 8:22 am

thank you!

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Minor and major tick with DateAxis and ValueAxis for ECG

Post by paradoxoff » Wed Oct 15, 2008 7:07 pm

gizza wrote: About hiding ticks:
if i hide a tick this will result in a hidden 'tick label' but also the grid line referring to the tick will be hidden?
Technically, you can´t "hide ticks". A tick is nothing "visual" by itself. It is an object that contains a text and, for a ValueTick, also a value and a tick type ("major" or "minor").

During the drawing process, a "list of ticks" is used that might either be created automatically or defined by the user. The information in the "tick list" is used by XYPlot and the ValueAxis (or better one of the subclasses of the abstract class ValueAxis) to "visualize" things:
The XYPlot can draw grid lines for every tick (see XYPlot.drawDomainGridLines and XYPlot.drawRangeGridLines), and
the ValueAxis can draw tick marks and (for major ticks) tick labels for each tick (see ValueAxis.drawTickMarksAndLabels).

The grid lines of the XYPlot and the tick marks and tick labels of the axis are independent. The switches to turn them on and off are located in different classes. So it should be possible to show minor tick marks (w/o label) on the axis and omit the grid lines for the minor ticks or get the grid lines for minor ticks (possibly using a thinner stroke or a lighter color than the the grid for the major ticks) and turn off the minor tick marks.

With my local JFreeChart installation, I have also realized a combination of hidden major grid lines, visible minor grid lines, visible major tick marks but hidden tick labels and hidden minor tick marks but that looked weird.
In short: I assume that you will have all degrees of freedom that you need.

Locked