Page 1 of 1

Bug on legend width in line chart?

Posted: Wed May 18, 2011 2:44 pm
by 7667590
Hi,

I have a line chart. When user wants to increase the line width, it will also increase the line width(thickness) in the legend. Is there a way to reset the line width=1 by default only in legend such that it looks better?

Here is a run-as sample code. I also attach a result of this code. The first and second ones are when the line width is 50 and 5, respectively.

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 l = new Line(chart.getChart());
		l.add(10, 10);
		l.add(20, 20);
		l.add(30, 30);
		l.getPointer().setStyle(PointerStyle.DIAMOND);
		l.getPointer().setVisible(true);
		l.setTitle("Line");
		
		l.getLinePen().setWidth(5);
		
		chart.getLegend().getSymbol().setWidthUnits(LegendSymbolSize.PIXELS);

		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);
	}

Re: Bug on legend width in line chart?

Posted: Fri May 20, 2011 12:12 pm
by yeray
Hello Jonathan,

Yes, you can modify the legend symbols pen as in the example at "All features\Welcome!\Miscellaneous\Legend\Symbols Border" in the feature demo program included with the installation folder \Examples\Swing\Features\TeeChart.Features.jar.
Here it is the code snipped:

Code: Select all

        tChart1.getLegend().getSymbol().setDefaultPen(false);
        tChart1.getLegend().getSymbol().getPen().setWidth(1);