Custom Tick Labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
TimK
Posts: 1
Joined: Sat Feb 17, 2007 3:25 am

Custom Tick Labels

Post by TimK » Sat Feb 17, 2007 3:29 am

I have a chart created from a TimeSeries, with dates on the x-axis, and integers on the y-axis, and I want to be able to specify arbitrary tick labels for certain y-values. For example, at the point where y=1200, I want a tick with label "1k", and at y=1300, I want a tick with label "1d". How can I do this?

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

Post by skunk » Sat Feb 17, 2007 3:35 pm

Code: Select all

org.jfree.chart.axis.SymbolAxis

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 » Mon Feb 19, 2007 11:35 am

SymbolAxis might be a little restrictive, since it assumes integer values 0, 1, 2, ...

Another option would be to subclass the NumberAxis class and override the refreshTicks() method.
David Gilbert
JFreeChart Project Leader

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

znasim
Posts: 10
Joined: Wed Feb 20, 2008 7:06 am

Custom Y axis Label

Post by znasim » Wed Mar 26, 2008 3:45 pm

Dear all,

I did a drawing of volume chart, and my volume data is very large. i.e like 345566 to 2332223. and i need to display the volume data in y axis as like
345K and 2.3M.

my code is

private DefaultCategoryDataset methodForVolume(Object[][] _result) {

dataset.clear();
int length = _result.length;
//double[] s_Last = new double[length];
double[] volume = new double[length];
double[] open = new double[length];
double[] close = new double[length];

for(int i=0; i<_result.length;i++) {
Date e_Date = (Date) _result[0];

open = ((Float) _result[2]).doubleValue();
close =((Float) _result[5]).doubleValue();

volume =((Long) _result[6]).doubleValue();

if(volume>0 && volume<999999)
volume=(volume[i]/1000);
if(volume[i]>999999 && volume[i]<99999999)
volume[i]=(volume[i]/10000);
dataset.addValue(volume[i],"",new Millisecond(0,e_Date.getSeconds(),e_Date.getMinutes(),e_Date.getHours(),e_Date.getDate(),e_Date.getMonth()+1,e_Date.getYear()+1900));
// dataset.addValue(volume[i],"",new Millisecond(0,e_Date.getSeconds(),e_Date.getMinutes(),e_Date.getHours(),e_Date.getDay(),e_Date.getMonth()+1,e_Date.getYear()+1900));
}
chartForBar = ChartFactory.createBarChart(null," ",null,dataset,PlotOrientation.VERTICAL,true,true,false);

Note :- PLease help me how i can change the Y axis value

Thanks

Locked