Page 1 of 1

horizontal pareto chart

Posted: Wed Jan 04, 2012 10:48 pm
by 7667590
Hi
I have a vertical pareto chart by using bar teechart object. If I want to see it as horizontal pareto chart, how can I do that? Is it possible to rotate the axis such that bottom axis become a left axis, and the left axis becomes a top axis?

Re: horizontal pareto chart

Posted: Thu Jan 05, 2012 8:19 am
by narcis
Hi Jonathan,

No, you should use HorizBar series instead of Bar series. Do the same you already do with Bar but using HorizBar.

Hope this helps!

Re: horizontal pareto chart

Posted: Thu Jan 05, 2012 4:05 pm
by 7667590
Hi,

Yes, it helps. thanks for the help.

I have two more questions.

Question1)
When I use HorizBar, I noticed that x axis on the bottom by default. Is it possible to have it to the top axis instead?

Question2)
When I re-label on the left axis, it also replace the markers. How can I prevent it? I tried using the setLabels built-in function to replace the markers, but it also replaces the labels as well. The following is a sample.

Code: Select all

package com.amd.ngeda.chart.teechart;

import java.util.HashMap;
import java.util.Map;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.steema.teechart.TChart;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.styles.Bar;
import com.steema.teechart.styles.Box;
import com.steema.teechart.styles.HorizBar;
import com.steema.teechart.styles.Line;
import com.steema.teechart.styles.StringList;

public class JonathanTest {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		JPanel panel = new JPanel();
		panel.setSize(600, 600);
		TChart chart = new TChart();
		panel.add(chart);
		
		HorizBar b = new HorizBar(chart.getChart());
		b.add(1, 0, "A");
		b.add(2, 1, "B");
//		StringList labelsList =  new StringList(2);
//		labelsList.add(0, "1");
//		labelsList.add(1, "2");
//		b.setLabels(labelsList);
		
		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);
	}
}


Re: horizontal pareto chart

Posted: Mon Jan 09, 2012 8:34 am
by yeray
Hi Jonathan,
Jonathan wrote:Question1)
When I use HorizBar, I noticed that x axis on the bottom by default. Is it possible to have it to the top axis instead?
Yes, you can do it as follows:

Code: Select all

b.setHorizontalAxis(HorizontalAxis.TOP);
Jonathan wrote:Question2)
When I re-label on the left axis, it also replace the markers. How can I prevent it? I tried using the setLabels built-in function to replace the markers, but it also replaces the labels as well. The following is a sample.
If your series (b in your case) has values with texts/labels, the axis linked to it shows these texts by default. And changing the series strings affects both the series marks and the axis labels.
You have two options:
- Change axis style to VALUE in example:

Code: Select all

tChart1.getAxes().getLeft().getLabels().setStyle(AxisLabelStyle.VALUE);
- Custom Labels: Clear and set the axis labels manually:

Code: Select all

	      AxisLabelsItems LeftAxisLabels = tChart1.getAxes().getLeft().getLabels().getItems();
	      LeftAxisLabels.clear();
	      LeftAxisLabels.add(0.0, "1");
	      LeftAxisLabels.add(1.0, "2");

Re: horizontal pareto chart

Posted: Mon Jan 09, 2012 4:58 pm
by 7667590
Hi Yeray,

Thanks for the help and answering my questions.