missing X labels on multiple line series

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Jonathan
Newbie
Newbie
Posts: 60
Joined: Tue Mar 11, 2008 12:00 am
Location: Austin

missing X labels on multiple line series

Post by Jonathan » Tue Mar 09, 2010 5:35 pm

Hi,
When I created two line series, x labels from the 1st series are missing. ex)

Code: Select all

	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);

		Line line1 = new Line(chart.getChart());
		line1.add(1, 4, "D"); //index, value, label
		line1.add(3, 2, "C");

		Line line2 = new Line(chart.getChart());
		line2.add(0, 1, "A");
		line2.add(2, 2, "B");
		
		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);
	}
In this code, I should have A, D, B, C as X labels. However, I have only A and B. How would I displayed all labels with remaining the lines?

(Interesting note: while the 1st code displayed all index values, the 2nd code doesn't displayed all text labels)

Code: Select all

chart.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.VALUE);

Code: Select all

chart.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.TEXT);

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: missing X labels on multiple line series

Post by Yeray » Wed Mar 10, 2010 3:26 pm

Hi Jonathan,

Take a look at this thread where this has been already discussed. Resuming, you can use custom labels or a dummy series with all the values set as null, but with all the labels you would like to appear.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Jonathan
Newbie
Newbie
Posts: 60
Joined: Tue Mar 11, 2008 12:00 am
Location: Austin

Re: missing X labels on multiple line series

Post by Jonathan » Thu Mar 11, 2010 5:43 pm

Hi,

I read the thread, but no luck. I pasted the codes I tried. Pls. help me how to display "A", "D", "B", "C" on x axis on my chart.

Code: Select all

	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);

		Line line1 = new Line(chart.getChart());
		line1.add(1, 4, "D"); //index, value, label
		line1.add(3, 2, "C");

		Line line2 = new Line(chart.getChart());
		line2.add(0, 1, "A");
		line2.add(2, 2, "B");
		
		//chart.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.VALUE);
		chart.getAxes().getBottom().getLabels().getItems().clear();
		chart.getAxes().getBottom().getLabels().getItems().add("A");
		chart.getAxes().getBottom().getLabels().getItems().add("D");
		chart.getAxes().getBottom().getLabels().getItems().add("B");
		chart.getAxes().getBottom().getLabels().getItems().add("C");
		
		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);
	}

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: missing X labels on multiple line series

Post by Yeray » Fri Mar 12, 2010 4:35 pm

Hi Jonathan,

Try with the ...getItems().add(double, string) method. To create the custom labels you have to control what is written on them but also where. The following seems to work fine here:

Code: Select all

        Line line1 = new Line(tChart1.getChart());
        line1.add(1, 4, "D"); //index, value, label
        line1.add(3, 2, "C");

        Line line2 = new Line(tChart1.getChart());
        line2.add(0, 1, "A");
        line2.add(2, 2, "B");
              
        tChart1.getAxes().getBottom().getLabels().getItems().clear();
        for (int i=0;i<tChart1.getSeriesCount();i++)
        {
            for (int j=0;j<tChart1.getSeries(i).getCount();j++)
            {
                tChart1.getAxes().getBottom().getLabels().getItems().add(tChart1.getSeries(i).getXValues().getValue(j), tChart1.getSeries(i).getLabels().getString(j));
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ZooX
Newbie
Newbie
Posts: 18
Joined: Tue Aug 25, 2009 12:00 am

Re: missing X labels on multiple line series

Post by ZooX » Wed Mar 24, 2010 5:00 pm

This is not the best way to do this, for every series you have you will be over-drawing the label which looks like hell.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: missing X labels on multiple line series

Post by Yeray » Fri Mar 26, 2010 3:05 pm

Hi ZooX,

You could add some condition in the for loop where the custom labels are added to control that manually.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ZooX
Newbie
Newbie
Posts: 18
Joined: Tue Aug 25, 2009 12:00 am

Re: missing X labels on multiple line series

Post by ZooX » Mon Jun 14, 2010 6:13 pm

I could but don't you think as a paid for library you should handle this?

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: missing X labels on multiple line series

Post by Yeray » Thu Jun 17, 2010 11:16 am

Hi ZooX,

I've added it to the wish list to be implemented in future releases (TJ71014978).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply