3DBarChart x Axis problem 3D rendering

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

3DBarChart x Axis problem 3D rendering

Post by reboot » Thu Jan 08, 2009 10:15 am

Greetings!

I'm a new user of JFreeChart. I'm working on old project, which uses JfreeChart library 1.0.6 and jdk 1.3, so i would like to know which is the latest compatible version of jfreechart... i would like to update if it is possible...


I have developed an interface java project to make userfriendly this library to the other java developer in my group.
But i got a problem... i have just developed the interface to manage a 3DBarChart with a single series and group for each entity in the chart.

It's like an histogram, but i need the 3D rendering so i used the 3DBarCHart...cose the histogram is not possibile to make it 3D.

The chart works properly but is not a true 3D... it dosnt has the axis X rendering... so the chart is 3D only on the Y a Z axis...


I assumed that this behavior due to huge amount of data... infact i have also modified the MaximumCategoryLabelLines to avoid the problem of 3dots instad the name of the category.

im sorry for my english, i would like to post an image but i cannot...i'll do soon... can some one help me?

reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

Post by reboot » Thu Jan 08, 2009 12:44 pm

is it possible that depends by the maximum 3d bar width? should i set it?

because the width bar chart seems tiny due the amount of data...but there are only 20 categories....


here is the phto, following the advise in the sticky post



img84.imageshack.us/my.php?image=reportreportgraficohl6.png

kalle
Posts: 36
Joined: Wed Dec 31, 2008 4:17 pm

Post by kalle » Thu Jan 08, 2009 1:12 pm

I ran into this myself. Try describing your data as a table, and work yourself forward from there. I quess those are all different things, so you want different colors?

This is what I guess you have going on (I fell here too):

Code: Select all

Data is like this:

       item1 item2 item3 item4
series1  1
series2       2
series3             3
series4                    4

This causes it to break. It should be either:

         item1 item2 item3 item4
series1   1      2     3      4

Or:

        item1
series1   1
series2   1
series3   1
series4   1
What makes bars tiny is that there are EMPTY bars in there. The col/row matches with no data.

If you still have issues after this info: show us how you setup your dataset and I think this will be solved.

reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

Post by reboot » Thu Jan 08, 2009 2:32 pm

Code: Select all

String seriesLabel;
		//Istanzione il DefaultCategoryDataset
		DefaultCategoryDataset singleDefaultCategoryDataSet = new DefaultCategoryDataset();
		Iterator itDataMap = dataMap.keySet().iterator();
			
			//Scorro il keySet della mappa e valorizzo secondo gli stadard il defaultCategoryDataSet
			while(itDataMap.hasNext()){
		
				String dataMapKey = (String) itDataMap.next();
				Number dataMapValue = (Number) this.dataMap.get(dataMapKey);							
				seriesLabel = dataMapKey+" = "+dataMapValue;
				
				//Valore Associato - SeriesLabel - Nome Entità
				singleDefaultCategoryDataSet.addValue(dataMapValue, seriesLabel, dataMapKey);
		
			}
		
		return singleDefaultCategoryDataSet;
	}


i got something like this

EntityCOde  Entity Value
A                1
B                2
C                10
D                35
E                 17

etc etc

Well is not essential for me to have different color for each entity in the chart.
I'm traing to clone the beahvior of an histogrm with a 3DBarchart. So the final target for me is to create a chart to display this data.

for example, imagine to have an HashMap(KEY,VALUE) and to create a 3Dbarchart...

I know that the 3DBARCHART is not been created to clone an histogram... but im tring to do it....

i have understood what u have wrote, i suppose that is not possble to do what i need......



well i have modified the seriesLabel value so now i got this data organization

Code: Select all


seriesName    uniqueCategory

series1          value
series2          value


this is the chart...

img383.imageshack.us/my.php?image=20090108150257083mx7.png

but his is not what i need.... :(

may i use this data organization ??




Code: Select all



       item1 item2 item3 item4
series1  1   0        0       0
series2  0   2        0       0
series3  0   0        3       0
series4  0   0        0       4   
and then i set the chart to not show the data with zero values....humm but i loss my entity with zero value....
[/code]

kalle
Posts: 36
Joined: Wed Dec 31, 2008 4:17 pm

Post by kalle » Thu Jan 08, 2009 4:22 pm

So is the order of bars or the width of bars the issue?

Your latest screenshot showed that the bars got thicker when you applied

Code: Select all

seriesName    uniqueCategory

series1          value
series2          value 
Is this not what was wanted?

reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

Post by reboot » Thu Jan 08, 2009 4:32 pm

no the problem is the width of the bar. in the last histogram i got i single category.

Instead i need a single category for each couple of data KEY-VALUE

i need the chart organization in the first image but with the bar widht ...

it should look likes this ...


img392.imageshack.us/img392/4240/immagineio4.png

i'm sorry is difficult to explain :D i need of a simple histogram but with a 3d rendering...

reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

Post by reboot » Thu Jan 08, 2009 10:27 pm

well i have tried at home, with a simple 3DbarChart using this default data.

Code: Select all

String series1 = "AO";
String series2 = "BO";
String series3 = "COA";
String series4 = "COB";
String series5 = "COV";
String series6 = "COC";
String series7 = "COD";
String series8 = "COE";
String series9 = "COH";
String series10 = "COI";
String series11 = "COL";
// column keys...
String type1 = series1;
String type2 = series2;
String type3 = series3;
String type4 =series4;
String type5 = series5;
String type6 = series6;
String type7 = series7;
String type8 = series8;
String type9 = series9;
String type10 = series10;
String type11 = series11;


// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset();

dataset.addValue(1.0, series1, type1);
dataset.addValue(4.0, series2, type2);
dataset.addValue(3.0, series3, type3);
dataset.addValue(5.0, series4, type4);
dataset.addValue(5.0, series5, type5);
dataset.addValue(7.0, series6, type6);
dataset.addValue(7.0, series7, type7);
dataset.addValue(8.0, series8, type8);
dataset.addValue(8.0, series9, type9);
dataset.addValue(8.0, series10, type10);
dataset.addValue(8.0, series11, type11);
the result is ok, i suppose that the problem wih the width due to lot of data. Infact the bars which compose the chart seem to be autoresized.

u can look at this image

img523.imageshack.us/my.php?image=schermata2li6.png

So now the question is... can i set a standard dimension for each bar that composes the CHART? so if the image dimension is set, it will be autoresized "the image" but not the bars size of the chart.

good night :D

thanks a lot whole of you, thanks again kalle.


p.s i'd like to know if it is possible to set for each series its value at the top of the bar

kalle
Posts: 36
Joined: Wed Dec 31, 2008 4:17 pm

Post by kalle » Fri Jan 09, 2009 7:03 am

Ok, let's see if we can get this right:

Code: Select all

If data is like this you will get 4 bars in 4 categories (4*4 bars).

       item1 item2 item3 item4 
series1  1    1    1     1
series2  2    2    2     2
series3  3    3    3     3 
series4  4    4    4     4 

         item1 item2 item3 item4 
series1   1      2     3      4 

This gives you 1 bar in 4 categories

        item1 
series1   1 
series2   1 
series3   1 
series4   1 

This gives you 4 bars in 1 category.

All of those will work for you. But as you show, your code creates single value per series-category combination, and this results in empty space. Note that it is not empty, it has plotted the space for your 11*11 bars.
So for example if you map it like this; series called 'value' (for all categories), and categories like they are now.

Does that make sense to you?

reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

Post by reboot » Fri Jan 09, 2009 9:31 am

Yes i understood, the dataSet populated in my way is like a diagonal matrix

i have created something like this...

Code: Select all


         column1    column2 column3 column4 column5
row1	 1	         null	      null	      null     null
row2	 null	         1	      null	      null     null	
row3	 null	         null	      1 	      null     null
row4	 null	         null	      null	      1        null
row5	 null	         null	      null	      null     1
im using the 3dBarChart improperly...i suppose...


i got a dubt... finally i must create a chart about a single category(column)


for example

Code: Select all

              appleNumber

davide     3
daniele    4
george    7
kalle       8

well this is created in the dataset

Code: Select all

dataSet.addValue(davide, "apple", 3)
dataSet.addValue(daniele, "apple", 4)
dataSet.addValue(george, "apple", 7)
dataSet.addValue(kalle,    "apple", 8)

well the chart will be ok with lot of tiny bar...but in the legend i'll got only one category and i'll loose all info about the series(row)....
well i suppose that this is the right way to use 3DbarChart... ^_^ thank u very muchhhhh ;D

kalle
Posts: 36
Joined: Wed Dec 31, 2008 4:17 pm

Post by kalle » Fri Jan 09, 2009 10:00 pm

It seems there is a link missing here. You see, in category chart you (should) have value in each category for each series. Like if you think of temperature in different cities (temperature being the series, cities the category).

If you have the diagonal dataset, you'll get those empty spaces for missing data that causes thin bars.

If you use CategoryPlot, you should design your design for it. You could try using a bar renderer with xy chart and custom x axis. (if you really need it)

I've yet to understand the nature of your data, but if you use it the other way around, having categories for names, and apples as series, then I guess it'd look like you want it.

Locked