Page 1 of 1

Android : PieChart not circular.

Posted: Fri Feb 15, 2013 11:10 am
by 17064948
Hi,

I have a problem with some pie, when i have too long and too much labels. The pie is not circular anymore.

What can i do to keep it circular ? I don't mind if it has to be smaller, but i don't want to see something like that (see attachment).

I use the following code to layout my chart :

Code: Select all

	private void layoutPieChart(TChart chart) {
		chart.getPanel().setBorderRound(15);
		chart.getPanel().getPen().setColor(new Color(getResources().getColor(R.color.value_neg)));
		chart.getPanel().setColor(new Color(getResources().getColor(R.color.white)));
		chart.getAspect().setView3D(true);
		chart.getHeader().getFont().setColor(new Color(getResources().getColor(R.color.blue_dark)));
		chart.getHeader().getFont().setSize(15);
		chart.getAspect().setOrthogonal(true);
		ColorPalettes.applyPalette(chart.getChart(), TChartUtil.getPalette());
		chart.getLegend().setAlignment(LegendAlignment.BOTTOM);
		chart.getLegend().getFont().setSize(15);
		chart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
		chart.getLegend().setTransparent(true);
		chart.getWalls().getBack().setVisible(false);
		chart.getCanvas().setBackColor(new Color(getResources().getColor(R.color.value_neg)));
		((com.steema.teechart.styles.Pie) chart.getSeries(0)).setCircled(true);
		((com.steema.teechart.styles.Pie) chart.getSeries(0)).getMarks().setVisible(false);
		((com.steema.teechart.styles.Pie) chart.getSeries(0)).getPen().setVisible(true);
	}


Thanks for your help.

Lionel

Re: Android : PieChart not circular.

Posted: Mon Feb 18, 2013 8:30 am
by yeray
Hi Lionel,

Are you sure the code you posted produces the chart in the image you attached? I see in the code the lines:

Code: Select all

chart.getAspect().setView3D(true);
((com.steema.teechart.styles.Pie) chart.getSeries(0)).getMarks().setVisible(false);
But the pie in the image seems to be 2D and the marks are shown.
Could you please revise it?

Re: Android : PieChart not circular.

Posted: Mon Feb 18, 2013 8:39 am
by 17064948
My bad, I paste the wrong code

Code: Select all

	
mTChart = (TChart) rootView.findViewById(R.id.chart);
		
mTChart.getAspect().setView3D(false);
mTChart.getAspect().setOrthogonal(true);

// mTChart.getPanel().setMarginLeft(20);
mTChart.getPanel().setColor(new Color(getResources().getColor(R.color.white)));
mTChart.getPanel().setBorderRound(10);
// Header
mTChart.getHeader().getFont().setSize(30);
mTChart.getHeader().setText(getString(R.string.pie_chart_perf_year_title));
mTChart.getHeader().getFont().setBold(true);
mTChart.getHeader().getFont()
				.setColor(new Color(getResources().getColor(R.color.blue_dark)));
		
mTChart.getLegend().setVisible(false);


mTChart.getAxes().setVisible(true);
mTChart.getAxes().setDrawBehind(true);
mTChart.getWalls().setVisible(false);
ColorPalettes.applyPalette(mTChart.getChart(), TChartUtil.getPalette());


mTChart.addSeries(getMasterStats("ECO_SECT_D"));
mTChart.getSeries(0).getMarks().setTransparent(true);
mTChart.getSeries(0).getMarks().getFont().setSize(17);
mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);

Re: Android : PieChart not circular.

Posted: Mon Feb 18, 2013 3:28 pm
by yeray
Hello,

I can't still reproduce it with the following code:

Code: Select all

		Pie pie1 = new Pie(tChart1.getChart());
		pie1.setCircled(true);
		
		Random r = new Random();
		for (int i=0; i<20; i++) {
			pie1.add(5 + r.nextDouble() * 5, "long point label nÂș" + String.valueOf(i));
		}
		
		tChart1.getAspect().setView3D(false);
		tChart1.getAspect().setOrthogonal(true);

		// mTChart.getPanel().setMarginLeft(20);
		tChart1.getPanel().setColor(Color.WHITE);
		tChart1.getPanel().setBorderRound(10);
		// Header
		tChart1.getHeader().getFont().setSize(30);
		tChart1.getHeader().setText("My Title");
		tChart1.getHeader().getFont().setBold(true);
		tChart1.getHeader().getFont().setColor(Color.BLUE);
		      
		tChart1.getLegend().setVisible(false);

		tChart1.getAxes().setVisible(true);
		tChart1.getAxes().setDrawBehind(true);
		tChart1.getWalls().setVisible(false);
		ColorPalettes.applyPalette(tChart1.getChart(), 1);

		pie1.getMarks().setTransparent(true);
		pie1.getMarks().getFont().setSize(17);
		pie1.getMarks().setStyle(MarksStyle.LABELPERCENT);
2013-02-18_1625.png
2013-02-18_1625.png (85.83 KiB) Viewed 3777 times
There could still be something we are doing different. Are you using SWT or Swing? Are you using the latest TeeChart version (v2012.0808)?

Re: Android : PieChart not circular.

Posted: Mon Feb 18, 2013 4:28 pm
by 17064948
I just purchased your product 2 weeks ago.

"Build 3.2012.1120"


Actually, I use the same TChart to produce differents charts. When I select a type of chart, generate his Series with the following method.

Code: Select all

	private void generateChart(int chartType) {
		mTChart.getHeader().setText(getResources().getStringArray(R.array.chart_list)[chartType]);
		mTChart.removeAllSeries();
		switch (chartType) {
		case PIE_ASSET_CAT:
			mTChart.addSeries(getAssetCatRepartition());
			mTChart.getSeries(0).getMarks().setTransparent(true);
			mTChart.getSeries(0).getMarks().getFont().setSize(17);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);
//			mTChart.getLegend().setVisible(true);
//			mTChart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
//			mTChart.getLegend().getFont().setSize(17);
		
			break;
		case PIE_CAT_ECO_SECT:
			mTChart.addSeries(getMasterStats("ECO_SECT_D"));
			mTChart.getSeries(0).getMarks().setTransparent(true);
			mTChart.getSeries(0).getMarks().getFont().setSize(17);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);
//			mTChart.getLegend().setVisible(true);
//			mTChart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
//			mTChart.getLegend().getFont().setSize(10);
			break;
		case PIE_ECO_SECT:
			mTChart.addSeries(getDetailStats("ECO_SECT_D"));
			mTChart.getSeries(0).getMarks().setTransparent(true);
			mTChart.getSeries(0).getMarks().getFont().setSize(17);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);
//			mTChart.getLegend().setVisible(true);
//			mTChart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
//			mTChart.getLegend().getFont().setSize(10);
			break;
		case PIE_CONTINENT:
			mTChart.addSeries(getMasterStats("COUNTRY"));
			mTChart.getSeries(0).getMarks().setTransparent(true);
			mTChart.getSeries(0).getMarks().getFont().setSize(17);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);
//			mTChart.getLegend().setVisible(true);
//			mTChart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
//			mTChart.getLegend().getFont().setSize(17);
			break;
		case PIE_COUNTRY:
			mTChart.addSeries(getDetailStats("COUNTRY"));
			mTChart.getSeries(0).getMarks().setTransparent(true);
			mTChart.getSeries(0).getMarks().getFont().setSize(17);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);
//			mTChart.getLegend().setVisible(true);
//			mTChart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
//			mTChart.getLegend().getFont().setSize(10);
			break;
		case BAR_BONDS_MATURITY_DATE:
			mTChart.getLegend().setVisible(false);
			mTChart.addSeries(getMaturityDateRepartition());
			mTChart.getSeries(0).getMarks().setTransparent(false);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.VALUE);
			mTChart.getSeries(0).getMarks().setBackColor(new Color(getResources().getColor(R.color.blue_light_soft)));
			break;
		case PIE_CURRENCY:
			mTChart.addSeries(getDetailStats("CURRENCY"));
			mTChart.getSeries(0).getMarks().setTransparent(true);
			mTChart.getSeries(0).getMarks().getFont().setSize(17);
			mTChart.getSeries(0).getMarks().setStyle(MarksStyle.LABELPERCENT);
//			mTChart.getLegend().setVisible(true);
//			mTChart.getLegend().setTextStyle(LegendTextStyle.RIGHTPERCENT);
//			mTChart.getLegend().getFont().setSize(10);
			break;
		default:
			mTChart.getHeader().setText("Error invalid chart selection");
		}
		mCurrentChartType = chartType;
	}

Re: Android : PieChart not circular.

Posted: Tue Feb 19, 2013 10:10 am
by yeray
Hello Lionel,

I've checked your code and it gives me circled pies as soon as I add setCirled(true), that doesn't seem to be present in the last snipped of code you've posted.
And I've tried it now with TeeChart Java for Android v2012.1120.

Please, try to simplify your application to the minimum where the problem can still be reproduced. Then, attach the application here in the forums so we can run it as-is and reproduce the problem here.

Re: Android : PieChart not circular.

Posted: Tue Feb 19, 2013 10:18 am
by 17064948
I'm stupid ... didn't call setCirled(true) on my Pie() series.

Thank you a lot for your help, everything is now OK !

Great support service.

Lionel

Re: Android : PieChart not circular.

Posted: Tue Feb 19, 2013 10:20 am
by yeray
Hi Lionel,

Agh... well, glad to be helpful and happy to hear you found it.