本文整理匯總了Java中org.achartengine.renderer.XYMultipleSeriesRenderer.setYLabels方法的典型用法代碼示例。如果您正苦於以下問題:Java XYMultipleSeriesRenderer.setYLabels方法的具體用法?Java XYMultipleSeriesRenderer.setYLabels怎麽用?Java XYMultipleSeriesRenderer.setYLabels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.achartengine.renderer.XYMultipleSeriesRenderer
的用法示例。
在下文中一共展示了XYMultipleSeriesRenderer.setYLabels方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setChartSettings
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
protected void setChartSettings(XYMultipleSeriesRenderer renderer, String xTitle, String yTitle,
double xMin, double xMax, double yMin, double yMax, int axesColor, int labelsColor) {
//有關對圖表的渲染可參看api文檔
renderer.setChartTitle(mTitle);
renderer.setXTitle(xTitle);
renderer.setYTitle(yTitle);
renderer.setXAxisMin(xMin);
renderer.setXAxisMax(xMax);
renderer.setYAxisMin(yMin);
renderer.setYAxisMax(yMax);
renderer.setAxesColor(axesColor);
renderer.setLabelsColor(labelsColor);
renderer.setShowGrid(true);
renderer.setGridColor(Color.GREEN);
renderer.setXLabels(20);
renderer.setYLabels(10);
renderer.setXTitle("Time");
renderer.setYTitle(" ");
renderer.setYLabelsAlign(Paint.Align.RIGHT);
renderer.setPointSize((float) 3);
renderer.setShowLegend(false);
}
示例2: configureRenderer
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Set some ChartView settings
*
* @param XYRenderer
*/
private void configureRenderer(XYMultipleSeriesRenderer XYRenderer)
{
XYRenderer.setAxesColor(Color.LTGRAY);
XYRenderer.setLabelsColor(Color.LTGRAY);
XYRenderer.setZoomEnabled(false, false);
XYRenderer.setAxisTitleTextSize(16);
XYRenderer.setChartTitleTextSize(20);
XYRenderer.setLabelsTextSize(15);
XYRenderer.setLegendTextSize(15);
XYRenderer.setPointSize(5f);
int margin = mContext.getResources().getDimensionPixelSize(R.dimen.chart_title_margin);
XYRenderer.setMargins(new int[] {margin, margin, margin, margin});
XYRenderer.setShowGrid(true);
XYRenderer.setXLabelsAlign(Align.RIGHT);
XYRenderer.setYLabels(20);
// if in ScrollView, need set
XYRenderer.setInScroll(true);
}
示例3: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "2008", "2007" };
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 14230, 12300, 14240, 15244, 15900, 19200, 22030, 21200, 19500, 15500,
12600, 14000 });
values.add(new double[] { 5230, 7300, 9240, 10540, 7900, 9200, 12030, 11200, 9500, 10500,
11600, 13500 });
int[] colors = new int[] { Color.BLUE, Color.CYAN };
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0.5,
12.5, 0, 24000, Color.GRAY, Color.LTGRAY);
((XYSeriesRenderer) renderer.getSeriesRendererAt(0)).setDisplayChartValues(true);
((XYSeriesRenderer) renderer.getSeriesRendererAt(1)).setDisplayChartValues(true);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setXLabelsAlign(Align.LEFT);
renderer.setYLabelsAlign(Align.LEFT);
renderer.setPanEnabled(true, false);
// renderer.setZoomEnabled(false);
renderer.setZoomRate(1.1f);
renderer.setBarSpacing(0.5f);
return ChartFactory.getBarChartIntent(context, buildBarDataset(titles, values), renderer,
Type.STACKED);
}
示例4: buildRenderer
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
private XYMultipleSeriesRenderer buildRenderer(Context context) {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(16);
renderer.setChartTitleTextSize(0);
renderer.setLabelsTextSize(15);
renderer.setLegendTextSize(20);
renderer.setLegendHeight(22);
renderer.setPointSize(5f);
renderer.setMargins(new int[] { 20, 30, 15, 20 });
renderer.setChartTitle("");
renderer.setXTitle(context.getResources().getString(R.string.X));
renderer.setYTitle(context.getResources().getString(R.string.Y));
renderer.setXAxisMin(Graph.MIN_HEIGHT_X);
renderer.setXAxisMax(Graph.MAX_HEIGHT_X);
renderer.setYAxisMin(Graph.MIN_HEIGHT_Y);
renderer.setYAxisMax(Graph.MAX_HEIGHT_Y);
renderer.setAxesColor(Color.GRAY);
renderer.setLabelsColor(Color.LTGRAY);
renderer.setYLabelsAlign(Align.RIGHT);
renderer.setXLabels(20);
renderer.setYLabels(20);
renderer.setPanEnabled(true);
renderer.setZoomEnabled(true);
renderer.setShowGrid(true);
renderer.setXAxisBold(true);
renderer.setYAxisBold(true);
renderer.setZoomButtonsVisible(false);
renderer.setExternalZoomEnabled(true);
XYSeriesRenderer r = new XYSeriesRenderer();
r.setColor(context.getResources().getColor(R.color.graph_color));
r.setPointStyle(PointStyle.POINT);
r.setLineWidth(4f);
renderer.addSeriesRenderer(r);
return renderer;
}
示例5: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
XYMultipleSeriesDataset series = new XYMultipleSeriesDataset();
XYValueSeries newTicketSeries = new XYValueSeries("New Tickets");
newTicketSeries.add(1f, 2, 14);
newTicketSeries.add(2f, 2, 12);
newTicketSeries.add(3f, 2, 18);
newTicketSeries.add(4f, 2, 5);
newTicketSeries.add(5f, 2, 1);
series.addSeries(newTicketSeries);
XYValueSeries fixedTicketSeries = new XYValueSeries("Fixed Tickets");
fixedTicketSeries.add(1f, 1, 7);
fixedTicketSeries.add(2f, 1, 4);
fixedTicketSeries.add(3f, 1, 18);
fixedTicketSeries.add(4f, 1, 3);
fixedTicketSeries.add(5f, 1, 1);
series.addSeries(fixedTicketSeries);
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(16);
renderer.setChartTitleTextSize(20);
renderer.setLabelsTextSize(15);
renderer.setLegendTextSize(15);
renderer.setMargins(new int[] { 20, 30, 15, 0 });
XYSeriesRenderer newTicketRenderer = new XYSeriesRenderer();
newTicketRenderer.setColor(Color.BLUE);
renderer.addSeriesRenderer(newTicketRenderer);
XYSeriesRenderer fixedTicketRenderer = new XYSeriesRenderer();
fixedTicketRenderer.setColor(Color.GREEN);
renderer.addSeriesRenderer(fixedTicketRenderer);
setChartSettings(renderer, "Project work status", "Priority", "", 0.5, 5.5, 0, 5, Color.GRAY,
Color.LTGRAY);
renderer.setXLabels(7);
renderer.setYLabels(0);
renderer.setShowGrid(false);
return ChartFactory.getBubbleChartIntent(context, series, renderer, "Project tickets");
}
示例6: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "Series 1", "Series 2", "Series 3", "Series 4", "Series 5" };
List<double[]> x = new ArrayList<double[]>();
List<double[]> values = new ArrayList<double[]>();
int count = 20;
int length = titles.length;
Random r = new Random();
for (int i = 0; i < length; i++) {
double[] xValues = new double[count];
double[] yValues = new double[count];
for (int k = 0; k < count; k++) {
xValues[k] = k + r.nextInt() % 10;
yValues[k] = k * 2 + r.nextInt() % 10;
}
x.add(xValues);
values.add(yValues);
}
int[] colors = new int[] { Color.BLUE, Color.CYAN, Color.MAGENTA, Color.LTGRAY, Color.GREEN };
PointStyle[] styles = new PointStyle[] { PointStyle.X, PointStyle.DIAMOND, PointStyle.TRIANGLE,
PointStyle.SQUARE, PointStyle.CIRCLE };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
setChartSettings(renderer, "Scatter chart", "X", "Y", -10, 30, -10, 51, Color.GRAY,
Color.LTGRAY);
renderer.setXLabels(10);
renderer.setYLabels(10);
length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
}
return ChartFactory.getScatterChartIntent(context, buildDataset(titles, x, values), renderer);
}
示例7: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "2007", "2008" };
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 5230, 7300, 9240, 10540, 7900, 9200, 12030, 11200, 9500, 10500,
11600, 13500 });
values.add(new double[] { 14230, 12300, 14240, 15244, 15900, 19200, 22030, 21200, 19500, 15500,
12600, 14000 });
int[] colors = new int[] { Color.CYAN, Color.BLUE };
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.VERTICAL);
setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0.5,
12.5, 0, 24000, Color.GRAY, Color.LTGRAY);
renderer.setXLabels(1);
renderer.setYLabels(10);
renderer.addXTextLabel(1, "Jan");
renderer.addXTextLabel(3, "Mar");
renderer.addXTextLabel(5, "May");
renderer.addXTextLabel(7, "Jul");
renderer.addXTextLabel(10, "Oct");
renderer.addXTextLabel(12, "Dec");
int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
XYSeriesRenderer seriesRenderer = (XYSeriesRenderer) renderer.getSeriesRendererAt(i);
seriesRenderer.setDisplayChartValues(true);
}
return ChartFactory.getBarChartIntent(context, buildBarDataset(titles, values), renderer,
Type.DEFAULT);
}
示例8: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "sin", "cos" };
List<double[]> x = new ArrayList<double[]>();
List<double[]> values = new ArrayList<double[]>();
int step = 4;
int count = 360 / step + 1;
x.add(new double[count]);
x.add(new double[count]);
double[] sinValues = new double[count];
double[] cosValues = new double[count];
values.add(sinValues);
values.add(cosValues);
for (int i = 0; i < count; i++) {
int angle = i * step;
x.get(0)[i] = angle;
x.get(1)[i] = angle;
double rAngle = Math.toRadians(angle);
sinValues[i] = Math.sin(rAngle);
cosValues[i] = Math.cos(rAngle);
}
int [] colors = new int[] { Color.BLUE, Color.CYAN };
PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
setChartSettings(renderer, "Trigonometric functions", "X (in degrees)", "Y", 0, 360, -1, 1,
Color.GRAY, Color.LTGRAY);
renderer.setXLabels(20);
renderer.setYLabels(10);
return ChartFactory.getLineChartIntent(context, buildDataset(titles, x, values), renderer);
}
示例9: renderGraph
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
public void renderGraph(Map<Long, Integer> scores){
removeAllViews();
String[] titles = new String[] { "" };
List<Date[]> dates = new ArrayList<Date[]>();
List<double[]> values = new ArrayList<double[]>();
int maxScore = 100;
Set<Long> keys = scores.keySet();
int i = keys.size() - 1;
if (0 > i){ return; }
Date[] dateValues = new Date[keys.size()];
double[] scoreValues = new double[keys.size()];
for (Long when : keys){
dateValues[i] = new Date(when);
int score = scores.get(when);
if (score > maxScore){ maxScore = score; }
scoreValues[i--] = score;
// store the last minimum date for later use by QamarGraphActivity
mMinimumDate = when;
}
dates.add(dateValues);
values.add(scoreValues);
int[] colors = new int[] { Color.BLUE };
PointStyle[] styles = new PointStyle[] { PointStyle.POINT };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
setChartSettings(renderer, dateValues[0].getTime(),
dateValues[dateValues.length - 1].getTime(),
0, maxScore + 100, Color.DKGRAY);
renderer.setYLabels(10);
renderer.setPanEnabled(false, false);
renderer.setZoomEnabled(false, false);
View view = ChartFactory.getTimeChartView(mContext,
buildDateDataset(titles, dates, values),
renderer, "MMM yyyy");
addView(view, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
}
示例10: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "Sales for 2008", "Sales for 2007",
"Difference between 2008 and 2007 sales" };
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 14230, 12300, 14240, 15244, 14900, 12200, 11030, 12000, 12500, 15500,
14600, 15000 });
values.add(new double[] { 10230, 10900, 11240, 12540, 13500, 14200, 12530, 11200, 10500, 12500,
11600, 13500 });
int length = values.get(0).length;
double[] diff = new double[length];
for (int i = 0; i < length; i++) {
diff[i] = values.get(0)[i] - values.get(1)[i];
}
values.add(diff);
int[] colors = new int[] { Color.BLUE, Color.CYAN, Color.GREEN };
PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT, PointStyle.POINT };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0.75,
12.25, -5000, 19000, Color.GRAY, Color.LTGRAY);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setChartTitleTextSize(20);
renderer.setTextTypeface("sans_serif", Typeface.BOLD);
renderer.setLabelsTextSize(14f);
renderer.setAxisTitleTextSize(15);
renderer.setLegendTextSize(15);
length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
XYSeriesRenderer seriesRenderer = (XYSeriesRenderer) renderer.getSeriesRendererAt(i);
if (i == length - 1) {
FillOutsideLine fill = new FillOutsideLine(FillOutsideLine.Type.BOUNDS_ALL);
fill.setColor(Color.GREEN);
seriesRenderer.addFillOutsideLine(fill);
}
seriesRenderer.setLineWidth(2.5f);
seriesRenderer.setDisplayChartValues(true);
seriesRenderer.setChartValuesTextSize(10f);
}
return ChartFactory.getCubicLineChartIntent(context, buildBarDataset(titles, values), renderer,
0.5f);
}
示例11: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "Air temperature" };
List<double[]> x = new ArrayList<double[]>();
x.add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2,
13.9 });
int[] colors = new int[] { Color.BLUE, Color.YELLOW };
PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT };
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(2);
setRenderer(renderer, colors, styles);
int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
XYSeriesRenderer r = (XYSeriesRenderer) renderer.getSeriesRendererAt(i);
r.setLineWidth(3f);
}
setChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, 0, 32,
Color.LTGRAY, Color.LTGRAY);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setShowGrid(true);
renderer.setXLabelsAlign(Align.RIGHT);
renderer.setYLabelsAlign(Align.RIGHT);
renderer.setZoomButtonsVisible(true);
renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });
renderer.setZoomRate(1.05f);
renderer.setLabelsColor(Color.WHITE);
renderer.setXLabelsColor(Color.GREEN);
renderer.setYLabelsColor(0, colors[0]);
renderer.setYLabelsColor(1, colors[1]);
renderer.setYTitle("Hours", 1);
renderer.setYAxisAlign(Align.RIGHT, 1);
renderer.setYLabelsAlign(Align.LEFT, 1);
renderer.setGridColor(colors[0], 0);
renderer.setGridColor(colors[1], 1);
XYMultipleSeriesDataset dataset = buildDataset(titles, x, values);
x.clear();
x.add(new double[] { -1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
values.clear();
values.add(new double[] { 4.3, 4.9, 5.9, 8.8, 10.8, 11.9, 13.6, 12.8, 11.4, 9.5, 7.5, 5.5 });
addXYSeries(dataset, new String[] { "Sunshine hours" }, x, values, 1);
Intent intent = ChartFactory.getCubicLineChartIntent(context, dataset, renderer, 0.3f,
"Average temperature");
return intent;
}
示例12: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
double[] minValues = new double[] { -24, -19, -10, -1, 7, 12, 15, 14, 9, 1, -11, -16 };
double[] maxValues = new double[] { 7, 12, 24, 28, 33, 35, 37, 36, 28, 19, 11, 4 };
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
RangeCategorySeries series = new RangeCategorySeries("Temperature");
int length = minValues.length;
for (int k = 0; k < length; k++) {
series.add(minValues[k], maxValues[k]);
}
dataset.addSeries(series.toXYSeries());
int[] colors = new int[] { Color.CYAN };
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
setChartSettings(renderer, "Monthly temperature range", "Month", "Celsius degrees", 0.5, 12.5,
-30, 45, Color.GRAY, Color.LTGRAY);
renderer.setBarSpacing(0.5);
renderer.setXLabels(0);
renderer.setYLabels(10);
renderer.addXTextLabel(1, "Jan");
renderer.addXTextLabel(3, "Mar");
renderer.addXTextLabel(5, "May");
renderer.addXTextLabel(7, "Jul");
renderer.addXTextLabel(10, "Oct");
renderer.addXTextLabel(12, "Dec");
renderer.addYTextLabel(-25, "Very cold");
renderer.addYTextLabel(-10, "Cold");
renderer.addYTextLabel(5, "OK");
renderer.addYTextLabel(20, "Nice");
renderer.setMargins(new int[] {30, 70, 10, 0});
renderer.setYLabelsAlign(Align.RIGHT);
XYSeriesRenderer r = (XYSeriesRenderer) renderer.getSeriesRendererAt(0);
r.setDisplayChartValues(true);
r.setChartValuesTextSize(12);
r.setChartValuesSpacing(3);
r.setGradientEnabled(true);
r.setGradientStart(-20, Color.BLUE);
r.setGradientStop(20, Color.GREEN);
return ChartFactory.getRangeBarChartIntent(context, dataset, renderer, Type.DEFAULT,
"Temperature range");
}
示例13: execute
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "New tickets", "Fixed tickets" };
List<Date[]> dates = new ArrayList<Date[]>();
List<double[]> values = new ArrayList<double[]>();
int length = titles.length;
for (int i = 0; i < length; i++) {
dates.add(new Date[12]);
dates.get(i)[0] = new Date(108, 9, 1);
dates.get(i)[1] = new Date(108, 9, 8);
dates.get(i)[2] = new Date(108, 9, 15);
dates.get(i)[3] = new Date(108, 9, 22);
dates.get(i)[4] = new Date(108, 9, 29);
dates.get(i)[5] = new Date(108, 10, 5);
dates.get(i)[6] = new Date(108, 10, 12);
dates.get(i)[7] = new Date(108, 10, 19);
dates.get(i)[8] = new Date(108, 10, 26);
dates.get(i)[9] = new Date(108, 11, 3);
dates.get(i)[10] = new Date(108, 11, 10);
dates.get(i)[11] = new Date(108, 11, 17);
}
values.add(new double[] { 142, 123, 142, 152, 149, 122, 110, 120, 125, 155, 146, 150 });
values.add(new double[] { 102, 90, 112, 105, 125, 112, 125, 112, 105, 115, 116, 135 });
length = values.get(0).length;
int[] colors = new int[] { Color.BLUE, Color.GREEN };
PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
setChartSettings(renderer, "Project work status", "Date", "Tickets", dates.get(0)[0].getTime(),
dates.get(0)[11].getTime(), 50, 190, Color.GRAY, Color.LTGRAY);
renderer.setXLabels(0);
renderer.setYLabels(10);
renderer.addYTextLabel(100, "test");
length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
XYSeriesRenderer seriesRenderer = (XYSeriesRenderer) renderer.getSeriesRendererAt(i);
seriesRenderer.setDisplayChartValues(true);
}
renderer.setXRoundedLabels(false);
return ChartFactory.getTimeChartIntent(context, buildDateDataset(titles, dates, values),
renderer, "MM/dd/yyyy");
}
示例14: onCreate
import org.achartengine.renderer.XYMultipleSeriesRenderer; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// keep main display on?
if(MainActivity.prefs.getBoolean("keep_screen_on", false))
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
// prevent activity from falling asleep
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
getString(R.string.app_name));
wakeLock.acquire();
// set up action bar
ActionBar actionBar = getActionBar();
if (actionBar != null)
{
actionBar.setDisplayShowTitleEnabled(true);
}
setTitle(R.string.chart);
/* get PIDs to be shown */
int positions[] = getIntent().getIntArrayExtra(POSITIONS);
// set up overall chart properties
sensorData = new XYMultipleSeriesDataset();
renderer = new XYMultipleSeriesRenderer(positions.length);
chartView = ChartFactory.getTimeChartView(this, sensorData, renderer, "H:mm:ss");
// set up global renderer
renderer.setXTitle(getString(R.string.time));
renderer.setXLabels(5);
renderer.setYLabels(5);
renderer.setGridColor(Color.DKGRAY);
renderer.setShowGrid(true);
renderer.setFitLegend(true);
renderer.setClickEnabled(false);
// set up chart data
setUpChartData(positions);
// make chart visible
setContentView(chartView);
// limit selected PIDs to selection
MainActivity.setFixedPids(pidNumbers);
// if auto hiding selected ...
if(MainActivity.prefs.getBoolean(MainActivity.PREF_AUTOHIDE,false))
{
// get autohide timeout [s]
int timeout = Integer.valueOf(
MainActivity.prefs.getString(MainActivity.PREF_AUTOHIDE_DELAY,"15") );
// auto hide toolbar
toolBarHider = new AutoHider( this,
mHandler,
MainActivity.MESSAGE_TOOLBAR_VISIBLE,
timeout * 1000);
toolBarHider.start(1000);
// wake up on touch
chartView.setOnTouchListener(toolBarHider);
}
}