I am struggling to move legend widget in androidplot to the place where I want.
I am trying to use androidplot to render a set of data. I followed the way of placing legend widget to a point by calling position() method used in DemoApp. But I never succeeded. I was blocked by this for almost 1 week. Can someone help me check whether i made some mistakes in my code. I did not find any documentation about how to use this lib except the sample code.
My layout xml:
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_below="@+id/seperator1"
androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.legendWidget.heightMetric.value="25dp"
androidPlot.graphWidget.marginBottom="25dp"
androidPlot.graphWidget.marginLeft="15dp"
androidPlot.graphWidget.marginRight="10dp"
androidPlot.graphWidget.marginTop="20dp"
androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp"
androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp"
androidPlot.legendWidget.positionMetrics.anchor="left_top"
androidPlot.legendWidget.positionMetrics.xPositionMetric.value="0"
androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"
androidPlot.legendWidget.widthMetric.value="100dp"
androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size" />
<!-- androidPlot.graphWidget.gridLinePaint.color="#000000"/> -->
My source code:
private void makePlotPretty() {
// use a 2x2 grid with room for 4 items:
plot.getLegendWidget().setTableModel(new DynamicTableModel(2, 2));
// add a semi-transparent black background to the legend
// so it's easier to see overlaid on top of our plot:
Paint bgPaint = new Paint();
bgPaint.setColor(Color.BLACK);
bgPaint.setStyle(Paint.Style.FILL);
bgPaint.setAlpha(255);
plot.getLegendWidget().setBackgroundPaint(bgPaint);
/* plot.getLegendWidget().setPositionMetrics(null);
*/
plot.getLegendWidget().setWidth(PixelUtils.dpToPix(40), SizeLayoutType.FILL);
plot.getGraphWidget().setRangeLabelHorizontalOffset(-1);
plot.getLegendWidget().position(125, XLayoutStyle.ABSOLUTE_FROM_LEFT, 100, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.LEFT_TOP);
}