x axis labels are replaced by custom labels in point chart

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

x axis labels are replaced by custom labels in point chart

Post by Jonathan » Tue Sep 01, 2009 4:39 pm

Hi, here is what I want to do. I have a simple point chart and want to display the custom label(, not x axis label) of each point by using Marktip when mouse is hovering over the point.

Case 1) When I set the labels starting from index 0, my labels("one","two","three") are displaying correctly. However, x axis labels are replaced by the custom labels, which should NOT be happened. Right?

Case 2) [Since Case1 does not work, I tried the following.] When I set the labels starting from index 1, x axis labels and displaying the labels work fine, except the 1st point since i set the label starting from index 1, instead of 0.

My Question is Why "case 1" doesn't work correctly? Is this a bug?? Or How can I fix this problem?

Here is the code for "Case1"

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);
		Points p = new Points(chart.getChart());
		p.add(3,6);
		p.add(4,7);
		p.add(5,10);
		
		StringList sl = new StringList(3);
		if(true){
			sl.setString(0, "one");
			sl.setString(1, "two");
			sl.setString(2, "three");
		}
		p.setLabels(sl);
		
		if(true){			
			MarksTip mt = new MarksTip(chart.getChart());
			mt.setStyle(MarksStyle.LABEL);
		}
				
		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);

	}
Here is the code for "Case2"

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);
		Points p = new Points(chart.getChart());
		p.add(3,6);
		p.add(4,7);
		p.add(5,10);
		
		StringList sl = new StringList(3);
		if(true){
			sl.setString(1, "one");
			sl.setString(2, "two");
			sl.setString(3, "three");
		}
		p.setLabels(sl);
		
		if(true){			
			MarksTip mt = new MarksTip(chart.getChart());
			mt.setStyle(MarksStyle.LABEL);
		}
				
		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);

	}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: x axis labels are replaced by custom labels in point chart

Post by Narcís » Wed Sep 02, 2009 9:21 am

Hi Jonathan,
My Question is Why "case 1" doesn't work correctly? Is this a bug?? Or How can I fix this problem?
If I understand this correctly, this is by design. When you are manually adding labels to a series, by default, they are automatically used as bottom axis labels. To change that you can change axis label style, for example:

Code: Select all

        tChart1.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.VALUE);
If this doesn't help don't hesitate to let us know.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Re: x axis labels are replaced by custom labels in point chart

Post by Jonathan » Wed Sep 02, 2009 2:23 pm

"When you are manually adding labels to a series, by default, they are automatically used as bottom axis labels." The statement is NOT true. If you look at the 'case 2' above, the bottom axis labels are NOT replaced by the custom labels("one","two","three") for points. In the 'case 2', I can see only 'two' and 'three' labels when mouse is hovering over the points (4,7) & (5,10). I don't see "one" over (3,6) because I set the points label starting index 1. Once I changed the starting index to 0 instead of 1 like 'case 1', x axis labels are replaced by the point label. I think this is a bug, isn't it? Basically, points can have 3 different bindings: one for x axis, another for y axis, and the other for point label itself. Please help me how to fix my 'case 2' issue. In other words, pls. help me how to display the points labels("one","two","three") without replacing x axis labels.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: x axis labels are replaced by custom labels in point chart

Post by Narcís » Thu Sep 03, 2009 7:51 am

Hi Jonathan,

No, this is not a bug. To achieve what you request you need to slightly modify your code like this:

Code: Select all

        Points p = new Points(tChart1.getChart());
        p.add(3,6);
        p.add(4,7);
        p.add(5,10);
        
        tChart1.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.VALUE);

        StringList sl = new StringList(3);
        if(true){
         sl.setString(0, "one");
         sl.setString(1, "two");
         sl.setString(2, "three");
        }
        p.setLabels(sl);

        MarksTip mt = new MarksTip(tChart1.getChart());
        mt.setStyle(MarksStyle.LABEL);
Or do as in the code below which is what I meant in my previous reply.

Code: Select all

        Points p = new Points(tChart1.getChart());
        p.add(3,6, "one");
        p.add(4,7, "two");
        p.add(5,10, "three");
        
        tChart1.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.VALUE);

        MarksTip mt = new MarksTip(tChart1.getChart());
        mt.setStyle(MarksStyle.LABEL);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply