I'm trying to make a doughnut chart with title in right aligment and chart in center of the linear layout.
this my render code:
DefaultRenderer renderer = buildCategoryRenderer(colors);
renderer.setShowLabels(true);
renderer.setInScroll(true);
renderer.setChartTitle("BEST TITLE IN THE WORLD");
renderer.setZoomEnabled(false);
renderer.setPanEnabled(false);// Disable User Interaction
renderer.setScale((float) 1.3);
renderer.setApplyBackgroundColor(true);
renderer.setBackgroundColor(Color.WHITE);
renderer.setStartAngle(0);
//didn't work: margins - an array containing the margin size values,
//in this order: top, left, bottom, right
int[] margins = {150,0,0,0};
renderer.setMargins(margins);
//if I set to false, title disappear
renderer.setShowLabels(true);
renderer.setShowLegend(false);
MultipleCategorySeries categorySeries = new MultipleCategorySeries(
"CONTENUTI");
categorySeries.add(labels, values);
donutGraph = ChartFactory.getDoughnutChartView(this,
categorySeries, renderer);
donutGraph.setLeft(10);
donutGraph.setOnClickListener(this);
parent.addView(donutGraph);
donutGraph.repaint();
this my xml code (only donut chart):
<!-- layout donut -->
<LinearLayout
android:id="@+id/pie_chart"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="0.5"
android:layout_margin="10dp"
android:orientation="horizontal"
android:background="#aadd66">
</LinearLayout>
this is the result:
my questions:
How can I change the origin of the donut? Should I do this with DefaultRenderer object or with GraphicalView?
how can I right align the title? (if it possible).
How can I show the title but not the label?
If you have a good tutorial, please tell me: I have to make a another scatter plot. Thank you very much!
2.how can I right align the title? (if it possible).
3.How can I show the title but not the label?
Make these changes in drawTitle()
method of RoundChart.java
public void drawTitle(Canvas canvas, int x, int y, int width, Paint paint) {
// if (mRenderer.isShowLabels()) {
paint.setColor(mRenderer.getLabelsColor());
paint.setTextAlign(Align.LEFT);
paint.setTextSize(mRenderer.getChartTitleTextSize());
drawString(canvas, mRenderer.getChartTitle(), x ,
y + mRenderer.getChartTitleTextSize(), paint); //REMOVE "+ width / 2"
// }
}