<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/sample_activity">
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
androidPlot.title="A Simple XY Plot"
androidPlot.domainLabel="Domain"
androidPlot.rangeLabel="Range"
androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size"
androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
androidPlot.graphWidget.marginTop="20dp"
androidPlot.graphWidget.marginLeft="15dp"
androidPlot.graphWidget.marginBottom="25dp"
androidPlot.graphWidget.marginRight="10dp"
androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"
androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp"
androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp"
androidPlot.legendWidget.heightMetric.value="25dp"
androidPlot.legendWidget.positionMetrics.anchor="right_bottom"
androidPlot.graphWidget.gridLinePaint.color="#000000"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="pie_segment_label_font_size">10dp</dimen>
<dimen name="title_font_size">20dp</dimen>
<dimen name="domain_label_font_size">13dp</dimen>
<dimen name="range_label_font_size">13dp</dimen>
<dimen name="range_tick_label_font_size">15dp</dimen>
<dimen name="domain_tick_label_font_size">15dp</dimen>
<dimen name="legend_text_font_size">20dp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<config
linePaint.strokeWidth="3dp"
linePaint.color="#00AA00"
vertexPaint.color="#007700"
fillPaint.color="#00000000"
pointLabelFormatter.textPaint.color="#FFFFFF"/>
<?xml version="1.0" encoding="utf-8"?>
<config
linePaint.strokeWidth="3dp"
linePaint.color="#0000AA"
vertexPaint.color="#000077"
fillPaint.color="#00000000"
pointLabelFormatter.textPaint.color="#FFFFFF"/>
package com.androidplot.demos;
import android.app.Activity;
import android.os.Bundle;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYSeries;
import com.androidplot.xy.*;
import java.util.Arrays;
/**
* A straightforward example of using AndroidPlot to plot some data.
*/
public class SimpleXYPlotActivity extends Activity
{
private XYPlot mySimpleXYPlot;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_xy_plot_example);
// initialize our XYPlot reference:
mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
// Create a couple arrays of y-values to plot:
Number[] series1Numbers = {1, 8, 5, 2, 7, 4};
Number[] series2Numbers = {4, 6, 3, 8, 2, 10};
// Turn the above arrays into XYSeries':
XYSeries series1 = new SimpleXYSeries(
Arrays.asList(series1Numbers), // SimpleXYSeries takes a List so turn our array into a List
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
"Series1"); // Set the display title of the series
// same as above
XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");
// Create a formatter to use for drawing a series using LineAndPointRenderer
// and configure it from xml:
LineAndPointFormatter series1Format = new LineAndPointFormatter();
series1Format.setPointLabelFormatter(new PointLabelFormatter());
series1Format.configure(getApplicationContext(),
R.xml.line_point_formatter_with_plf1);
// add a new series' to the xyplot:
mySimpleXYPlot.addSeries(series1, series1Format);
// same as above:
LineAndPointFormatter series2Format = new LineAndPointFormatter();
series2Format.setPointLabelFormatter(new PointLabelFormatter());
series2Format.configure(getApplicationContext(),
R.xml.line_point_formatter_with_plf2);
mySimpleXYPlot.addSeries(series2, series2Format);
// reduce the number of range labels
mySimpleXYPlot.setTicksPerRangeLabel(3);
}
}
graph.getGraphWidget().getRangeLabelPaint().setTextSize(25);
As you can see the yellow boxed labels are cut in half and the red boxed labels, while they look 'correct' are in fact missin a proceeding 2 - - they are temperatures and range from 23.1 to 27.4
Having set the domain and range label sizes the third issue pops up, the first two labels are smaller than the rest - looks like they are basically the original size.
Are these three issues bugs in the new version or just my poor understanding of AndroidPlot?
Thanks
Andy
plot.getGraphWidget().setMarginLeft(100); // or whatever value you determine works for your setup
plot.getGraphWidget().setMarginBottom(100); // same as above
PixelUtils.dpToPix(...)
plot.getGraphWidget.getDomainOriginLabelPaint();
plot.getGraphWidget.getRangeOriginLabelPaint();
androidPlot.titleWidget.labelPaint.textSize="20dp"
plot.getTitleWidget().getLabelPaint().setTextSize(PixelUtils.dpToPix(20);