本文整理汇总了Java中org.achartengine.ChartFactory类的典型用法代码示例。如果您正苦于以下问题:Java ChartFactory类的具体用法?Java ChartFactory怎么用?Java ChartFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChartFactory类属于org.achartengine包,在下文中一共展示了ChartFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPieChart
import org.achartengine.ChartFactory; //导入依赖的package包/类
private Intent createPieChart() {
DefaultRenderer renderer = new DefaultRenderer();
renderer.setLabelsTextSize(getResources().getDimension(R.dimen.report_labels_text_size));
renderer.setLegendTextSize(getResources().getDimension(R.dimen.report_legend_text_size));
renderer.setMargins(new int[] { 0, 0, 0, 0 });
ReportData report = currentReport.getReportForChart(db, WhereFilter.copyOf(filter));
CategorySeries series = new CategorySeries("AAA");
long total = Math.abs(report.total.amount)+Math.abs(report.total.balance);
int[] colors = generateColors(2*report.units.size());
int i = 0;
for (GraphUnit unit : report.units) {
addSeries(series, renderer, unit.name, unit.getIncomeExpense().income, total, colors[i++]);
addSeries(series, renderer, unit.name, unit.getIncomeExpense().expense, total, colors[i++]);
}
renderer.setZoomButtonsVisible(true);
renderer.setZoomEnabled(true);
renderer.setChartTitleTextSize(20);
return ChartFactory.getPieChartIntent(ReportActivity.this, series, renderer, getString(R.string.report));
}
示例2: onPostExecute
import org.achartengine.ChartFactory; //导入依赖的package包/类
@Override
protected void onPostExecute(Boolean b) {
//now run on UI thread
// possible on back pressed by the time of the task so handle if not view
if (getView()!=null) {
if ( getView().findViewById(R.id.chart_container)!=null) {
LinearLayout chartContainer = (LinearLayout) getView().findViewById(R.id.chart_container);
mChartView=ChartFactory.getPieChartView(ReportFragment.this.getActivity(), series, renderer);
chartContainer.removeAllViews();
chartContainer.addView(mChartView);
viewingPieChart=true;
getView().findViewById(android.R.id.list).setVisibility(View.GONE);
getView().findViewById(R.id.chart_container).setVisibility(View.VISIBLE);
getActivity().supportInvalidateOptionsMenu();
mChartView.zoomOut();
}
}
getActivity().setProgressBarIndeterminateVisibility(false);
long t=System.currentTimeMillis();
Log.d("Financisto", "Load time = " + (t - t0) + " ms");
}
示例3: renderGraph
import org.achartengine.ChartFactory; //导入依赖的package包/类
private void renderGraph() {
mSeries = new XYSeries("Vols/FreqBin");
div10 = new XYSeries("div10");
mSeries.add(3,4);
mRenderer = new XYSeriesRenderer();
div10Renderer = new XYSeriesRenderer();
div10Renderer.setColor(root.getResources().getColor(R.color.red));
dataset.addSeries(mSeries);
dataset.addSeries(div10);
renderer.addSeriesRenderer(mRenderer);
renderer.addSeriesRenderer(div10Renderer);
renderer.setPanEnabled(false);
renderer.setZoomEnabled(false);
mChart = ChartFactory.getLineChartView(getActivity(), dataset, renderer);
((LinearLayout)root.findViewById(R.id.chart)).addView(mChart);
}
示例4: execute
import org.achartengine.ChartFactory; //导入依赖的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);
}
示例5: execute
import org.achartengine.ChartFactory; //导入依赖的package包/类
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
double[] values = new double[] { 12, 14, 11, 10, 19 };
int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };
DefaultRenderer renderer = buildCategoryRenderer(colors);
renderer.setZoomButtonsVisible(true);
renderer.setZoomEnabled(true);
renderer.setChartTitleTextSize(20);
renderer.setDisplayValues(true);
renderer.setShowLabels(true);
SimpleSeriesRenderer r = renderer.getSeriesRendererAt(0);
r.setGradientEnabled(true);
r.setGradientStart(0, Color.BLUE);
r.setGradientStop(0, Color.GREEN);
r.setHighlighted(true);
Intent intent = ChartFactory.getPieChartIntent(context,
buildCategoryDataset("Project budget", values), renderer, "Budget");
return intent;
}
示例6: execute
import org.achartengine.ChartFactory; //导入依赖的package包/类
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 12, 14, 11, 10, 19 });
values.add(new double[] { 10, 9, 14, 20, 11 });
List<String[]> titles = new ArrayList<String[]>();
titles.add(new String[] { "P1", "P2", "P3", "P4", "P5" });
titles.add(new String[] { "Project1", "Project2", "Project3", "Project4", "Project5" });
int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };
DefaultRenderer renderer = buildCategoryRenderer(colors);
renderer.setApplyBackgroundColor(true);
renderer.setBackgroundColor(Color.rgb(222, 222, 200));
renderer.setLabelsColor(Color.GRAY);
return ChartFactory.getDoughnutChartIntent(context,
buildMultipleCategoryDataset("Project budget", titles, values), renderer,
"Doughnut chart demo");
}
示例7: onListItemClick
import org.achartengine.ChartFactory; //导入依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
switch (position) {
case 0:
Intent intent = ChartFactory.getLineChartIntent(this, getDemoDataset(), getDemoRenderer());
startActivity(intent);
break;
case 1:
intent = ChartFactory.getScatterChartIntent(this, getDemoDataset(), getDemoRenderer());
startActivity(intent);
break;
case 2:
intent = ChartFactory.getTimeChartIntent(this, getDateDemoDataset(), getDemoRenderer(), null);
startActivity(intent);
break;
case 3:
XYMultipleSeriesRenderer renderer = getBarDemoRenderer();
setChartSettings(renderer);
intent = ChartFactory.getBarChartIntent(this, getBarDemoDataset(), renderer, Type.DEFAULT);
startActivity(intent);
break;
}
}
示例8: onResume
import org.achartengine.ChartFactory; //导入依赖的package包/类
@Override
public void onResume()
{
super.onResume();
LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
if (mChart == null) {
initChart();
//addSampleData();
mChart = ChartFactory.getCubeLineChartView(this, mDataset, mRenderer, 0.3f);
layout.addView(mChart);
} else {
mChart.repaint();
}
trigger();
}
示例9: execute
import org.achartengine.ChartFactory; //导入依赖的package包/类
public GraphicalView execute(Context context){
int[] colors = new int[]{Color.GREEN, Color.LTGRAY, Color.BLUE, Color.RED, Color.DKGRAY, Color.MAGENTA};
DefaultRenderer renderer = buildCategoryRenderer(colors);
CategorySeries categorySeries = new CategorySeries("Resolution Ratio Chart");
// Calculating normalization coefficient
double valueSum = 0;
for(int i = 0;i < value.length;i++){
valueSum += value[i];
}
// Adding data to Series
for(int i = 0;i < Playbackquality.length;i++){
categorySeries.add(Playbackquality[i], value[i]/valueSum);
}
return ChartFactory.getPieChartView(context, categorySeries, renderer);
}
示例10: onCreateView
import org.achartengine.ChartFactory; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_food_sources, parent, false);
TextView mNutrientNameField = (TextView)v.findViewById(R.id.sources_for_nutrient);
mNutrientNameField.setText("Sources for: \n" + mNutrient.getName());
LinearLayout chart_holder = (LinearLayout) v.findViewById(R.id.chart);
if (mNutrient.getSources().size() == 0) {
TextView no_data = new TextView(getActivity());
no_data.setText("No data found");
chart_holder.addView(no_data);
} else {
if (mChart == null) {
addSampleData();
mChart = ChartFactory.getPieChartView(getActivity(), mDataset, mRenderer);
chart_holder.addView(mChart);
} else {
mChart.repaint();
}
}
return v;
}
示例11: updateChart
import org.achartengine.ChartFactory; //导入依赖的package包/类
private void updateChart() {
XYMultipleSeriesDataset data = new XYMultipleSeriesDataset();
CategorySeries correctSeries = new CategorySeries("Correct");
CategorySeries wrongSeries = new CategorySeries("Wrong");
int correct = mPlayStats.getNumberCorrect(mCard);
int wrong = mPlayStats.getNumberWrong(mCard);
mStatsLabel.setText(correct + " Correct, " + wrong + " Wrong");
correctSeries.add("Correct", correct);
wrongSeries.add("Wrong", wrong);
data.addSeries(correctSeries.toXYSeries());
data.addSeries(wrongSeries.toXYSeries());
barRenderer.setYAxisMax(Math.max(correct, wrong));
mBarChartView = ChartFactory.getBarChartView(getContext(), data, barRenderer, BarChart.Type.DEFAULT);
mChartLayout.removeAllViews();
mChartLayout.addView(mBarChartView);
}
示例12: createChart
import org.achartengine.ChartFactory; //导入依赖的package包/类
private GraphicalView createChart(Context context, ResponseGetDeviceInfo deviceInfo) {
int[] colors = new int[] { context.getResources().getColor(R.color.darkRed),
context.getResources().getColor(R.color.verdeOscuro)};
DefaultRenderer renderer = buildCategoryRenderer(colors);
renderer.setZoomButtonsVisible(true);
renderer.setZoomEnabled(true);
renderer.setChartTitleTextSize(20);
renderer.setLabelsColor(Color.BLACK);
CategorySeries categorySeries = new CategorySeries("");
try {
//Title in the graph
renderer.setChartTitle(deviceInfo.getAccessPath() + " ("+deviceInfo.getSizeHuman()+")"); //It is the drive name
long usedInNumeric = deviceInfo.getSize() - deviceInfo.getFreeDiskSpace();
//TODO i18n words 'used' and 'free'
categorySeries.add("Used " + deviceInfo.getUsedDiskSpaceHuman(), usedInNumeric);
categorySeries.add("Free " + deviceInfo.getFreeDiskSpaceHuman(), deviceInfo.getFreeDiskSpace());
} catch (Exception e) {
showToastError(R.string.error_parsing_data);
}
return ChartFactory.getPieChartView(context, categorySeries, renderer);
}
示例13: execute
import org.achartengine.ChartFactory; //导入依赖的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);
renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
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);
}
示例14: execute
import org.achartengine.ChartFactory; //导入依赖的package包/类
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
double[] values = new double[] { 12, 14, 11, 10, 19 };
int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };
DefaultRenderer renderer = buildCategoryRenderer(colors);
renderer.setZoomButtonsVisible(true);
renderer.setZoomEnabled(true);
renderer.setChartTitleTextSize(20);
renderer.setDisplayValues(true);
renderer.setShowLabels(false);
SimpleSeriesRenderer r = renderer.getSeriesRendererAt(0);
r.setGradientEnabled(true);
r.setGradientStart(0, Color.BLUE);
r.setGradientStop(0, Color.GREEN);
r.setHighlighted(true);
Intent intent = ChartFactory.getPieChartIntent(context,
buildCategoryDataset("Project budget", values), renderer, "Budget");
return intent;
}
示例15: 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;
}