本文整理汇总了Java中org.achartengine.ChartFactory.getTimeChartView方法的典型用法代码示例。如果您正苦于以下问题:Java ChartFactory.getTimeChartView方法的具体用法?Java ChartFactory.getTimeChartView怎么用?Java ChartFactory.getTimeChartView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.achartengine.ChartFactory
的用法示例。
在下文中一共展示了ChartFactory.getTimeChartView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import org.achartengine.ChartFactory; //导入方法依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater,
final ViewGroup container, final Bundle savedInstanceState) {
Log.d(TAG, "onCreateView");
if (Configuration.ORIENTATION_PORTRAIT == getResources()
.getConfiguration().orientation) {
mRenderer.setYLabels(15);
}
final LinearLayout view = (LinearLayout) inflater.inflate(
R.layout.fragment_daymode_chart, container, false);
mChartView = ChartFactory.getTimeChartView(getActivity(), mDataset,
mRenderer, TIME);
mChartView.addZoomListener(mZoomListener, true, false);
view.addView(mChartView, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
return view;
}
示例2: onResume
import org.achartengine.ChartFactory; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
layout = (LinearLayout) findViewById(R.id.chart);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, new IntentFilter(BaseActivity.MSG_SENSOR_DATA));
if (graphicalView == null) {
initChart();
graphicalView = ChartFactory.getTimeChartView(PlotActivity.this, dataSet, dataRenderer, "HH:mm:ss.SSS");
layout.addView(graphicalView);
}
}
示例3: renderGraph
import org.achartengine.ChartFactory; //导入方法依赖的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);
}
示例4: draw
import org.achartengine.ChartFactory; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void draw() {
ArrayList<String> dates;
ArrayList<Double> readings;
// assign the data passed to the intent
dates = getIntent().getStringArrayListExtra("dates");
readings = (ArrayList<Double>) getIntent().getSerializableExtra(
"readings");
title = getIntent().getStringExtra("test");
// create a new time series for the graph
TimeSeries series = new TimeSeries(title + " Results");
// populate the series with data retrieved from the database
for (int i = dates.size() - 1; i >= 0; i--) {
// parse the date object to calendar date time
try {
c.setTime(sdf.parse(dates.get(i)));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// add the current point to the time series
series.add(c.getTime(), readings.get(i));
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series); // initialize the set of data to be drawn
// Now create the renderer to control how the chart looks like
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setLineWidth(4);
renderer.setColor(Color.WHITE);
// add point markers
renderer.setPointStyle(PointStyle.CIRCLE);
renderer.setPointStrokeWidth(3);
renderer.setDisplayChartValues(true);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.addSeriesRenderer(renderer);
// avoid black border
mRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00)); // transparent
// margins
// Enable Pan on two axis
mRenderer.setPanEnabled(true, true);
mRenderer.setShowGrid(true); // show the grid
mRenderer.setXTitle("Day");
if (title.equals("HBA1C"))
mRenderer.setYTitle("%");
else
mRenderer.setYTitle("mg/dl");
mRenderer.setZoomButtonsVisible(true);
GraphicalView chartView = ChartFactory.getTimeChartView(DrawGraph.this,
dataset, mRenderer, "yyyy/MM/dd hh:mm aa");// combines the dataset with
// the renderer and returns
// a view
LinearLayout chart_container = (LinearLayout) findViewById(R.id.Chart_layout);
//set the created chart view to the linear layout of the layout created for the graph
chart_container.addView(chartView, 0);
}
示例5: onCreate
import org.achartengine.ChartFactory; //导入方法依赖的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);
}
}
示例6: getChartGraphicalView
import org.achartengine.ChartFactory; //导入方法依赖的package包/类
public GraphicalView getChartGraphicalView(Context context){
return ChartFactory.getTimeChartView(context, dataset, renderer,null);
}
示例7: drawChart
import org.achartengine.ChartFactory; //导入方法依赖的package包/类
private void drawChart() {
mRenderer = new XYMultipleSeriesRenderer();
mDataset = new XYMultipleSeriesDataset();
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setLineWidth(5);
renderer.setColor(Color.parseColor("#0099cc"));
renderer.setDisplayBoundingPoints(true);
renderer.setPointStyle(PointStyle.CIRCLE);
renderer.setPointStrokeWidth(10);
//FillOutsideLine fillOutsideLine = new FillOutsideLine(Type.BOUNDS_ALL);
//fillOutsideLine.setColor(Color.parseColor("#0099cc"));
//renderer.addFillOutsideLine(fillOutsideLine);
//mRenderer.setChartTitle("Battery Level (%)");
mRenderer.setChartTitleTextSize(30f);
mRenderer.setLabelsTextSize(20f);
mRenderer.addSeriesRenderer(renderer);
mRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
mRenderer.setPanEnabled(true, false);
mRenderer.setZoomEnabled(false, false);
mRenderer.setYAxisMax(DeviceUtils.getBatteryScale(getActivity()));
mRenderer.setYAxisMin(0);
//mRenderer.setShowGrid(true);
mRenderer.setGridColor(Color.GRAY);
mRenderer.setClickEnabled(false);
TimeSeries series = new TimeSeries("");
/* long value = new Date().getTime() - 3 * TimeChart.DAY;
for (int i = 0; i < 5; i++) {
series.add(new Date(value + i * TimeChart.DAY / 4), i);
}*/
List<BatteryTrace> traces = BatteryTrace.getClosestTraceData(getActivity().getContentResolver(), LIMIT_DATE_SHOW);
boolean chartVisible = traces.size() >= MINIMUM_VALUE_TO_SHOW_CHART;
if (chartVisible) {
Calendar panMinimumX = Calendar.getInstance();
panMinimumX.set(Calendar.HOUR_OF_DAY, traces.get(0).hour);
panMinimumX.set(Calendar.MINUTE, traces.get(0).minutes);
Calendar panMaximumX = Calendar.getInstance();
panMaximumX.set(Calendar.HOUR_OF_DAY, traces.get(traces.size()-1).hour);
panMaximumX.set(Calendar.MINUTE, traces.get(traces.size()-1).minutes);
//mRenderer.setPanLimits(new double[] {panMinimumX.getTimeInMillis(), panMaximumX.getTimeInMillis() * 2, 0, 0});
for (BatteryTrace b : traces) {
//System.out.println(b.toString());
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, b.hour);
c.set(Calendar.MINUTE, b.minutes);
series.add(c.getTime(), b.level);
}
mDataset.addSeries(series);
mChartView = ChartFactory.getTimeChartView(getActivity(), mDataset, mRenderer, "hh:mm aa");
}
}