Page 1 of 1

missing X labels on multiple line series

Posted: Tue Mar 09, 2010 5:35 pm
by 7667590
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);

Re: missing X labels on multiple line series

Posted: Wed Mar 10, 2010 3:26 pm
by yeray
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.

Re: missing X labels on multiple line series

Posted: Thu Mar 11, 2010 5:43 pm
by 7667590
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);
	}

Re: missing X labels on multiple line series

Posted: Fri Mar 12, 2010 4:35 pm
by yeray
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));
            }
        }

Re: missing X labels on multiple line series

Posted: Wed Mar 24, 2010 5:00 pm
by 15354147
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.

Re: missing X labels on multiple line series

Posted: Fri Mar 26, 2010 3:05 pm
by yeray
Hi ZooX,

You could add some condition in the for loop where the custom labels are added to control that manually.

Re: missing X labels on multiple line series

Posted: Mon Jun 14, 2010 6:13 pm
by 15354147
I could but don't you think as a paid for library you should handle this?

Re: missing X labels on multiple line series

Posted: Thu Jun 17, 2010 11:16 am
by yeray
Hi ZooX,

I've added it to the wish list to be implemented in future releases (TJ71014978).