当前位置: 首页>>代码示例>>Java>>正文


Java ChartFactory.getBarChartView方法代码示例

本文整理汇总了Java中org.achartengine.ChartFactory.getBarChartView方法的典型用法代码示例。如果您正苦于以下问题:Java ChartFactory.getBarChartView方法的具体用法?Java ChartFactory.getBarChartView怎么用?Java ChartFactory.getBarChartView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.achartengine.ChartFactory的用法示例。


在下文中一共展示了ChartFactory.getBarChartView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:PhaniGaddipati,项目名称:Stacks-Flashcards,代码行数:24,代码来源:StatsCardView.java

示例2: getView

import org.achartengine.ChartFactory; //导入方法依赖的package包/类
public View getView(MainActivity Main) {
	BuildChart(Main);
	
	return ChartFactory.getBarChartView(Main,
			buildBarDataset(titles, values), renderer, Type.DEFAULT);
}
 
开发者ID:jhmgbl,项目名称:learnforandroidfragAS,代码行数:7,代码来源:LearnBarChart.java

示例3: getView

import org.achartengine.ChartFactory; //导入方法依赖的package包/类
public GraphicalView getView(Context context) {
	int leftMargin = 30;
	int rightMargin = 20;
	
	int range = (ScreenWidth - leftMargin - rightMargin) / barCount;
	int barWidth = (ScreenWidth - leftMargin - rightMargin) / (barCount + 1);
	int yMax = -1;
	for (int i = 0; i < values.length; i++) {
		if(yMax < values[i]) yMax = values[i];
	}
	yMax += (yMax / 10);
	
	XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
	for (int i = 0; i < barCount; i++) {
		XYSeries bar = new XYSeries(verdictLabel[i]);
		bar.add(i + 1, values[i]);
		dataset.addSeries( bar );
	}

	XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
	mRenderer.setChartTitle(graphTitle);
	mRenderer.setApplyBackgroundColor(true);
	mRenderer.setBackgroundColor(Color.WHITE);
	mRenderer.setMarginsColor(Color.WHITE);
	mRenderer.setAxesColor(Color.BLACK);
	mRenderer.setYLabelsAlign(Align.RIGHT);
	mRenderer.setXLabelsColor(Color.BLACK);
	mRenderer.setLabelsColor(Color.BLACK);
	mRenderer.setYLabelsColor(0, Color.BLACK);

	mRenderer.setBarWidth(barWidth);
	mRenderer.setXAxisMin(-range);
	mRenderer.setXAxisMax(range + 10);
	mRenderer.setYAxisMax(yMax);
	mRenderer.setYAxisMin(0);
	mRenderer.setXLabels(0);
	mRenderer.setPanEnabled(false, false);
	mRenderer.setZoomEnabled(false);
	
	DisplayMetrics metrics = context.getResources().getDisplayMetrics();
	val = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, metrics);
       mRenderer.setAxisTitleTextSize(val);
       mRenderer.setChartTitleTextSize(val);
       mRenderer.setLabelsTextSize(val);
       mRenderer.setLegendTextSize(val);
       val = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16, metrics);
       mRenderer.setChartTitleTextSize(val);
	
	for (int i = 0; i < barCount; i++) {
		mRenderer.addSeriesRenderer(customization(ColorCode[i]));
	}

	return ChartFactory.getBarChartView(context, dataset, mRenderer,
			Type.DEFAULT);
}
 
开发者ID:kaidul,项目名称:uHunt_for_Android,代码行数:56,代码来源:BarGraphDrawer.java

示例4: openChart

import org.achartengine.ChartFactory; //导入方法依赖的package包/类
private void openChart(){
    XYSeries durationSeries = new XYSeries("Duration of travel");
    int timeLength = trafficStatList.size();
    for(int i = 0; i < timeLength; i++){
        durationSeries.add((i + 1), trafficStatList.get(i).getTravelTime());
    }

    XYSeries speedSeries = new XYSeries("Speed");
    for(int i = 0; i < timeLength; i++){
        speedSeries.add((i + 1), trafficStatList.get(i).getSpeed());
    }

    //Collects all series and adds them under one object here called data
    XYMultipleSeriesDataset data = new  XYMultipleSeriesDataset();
    data.addSeries(durationSeries);
    data.addSeries(speedSeries);

    //Gives the Bar it's property
    XYSeriesRenderer durRenderer = new XYSeriesRenderer();
    durRenderer.setColor(Color.GREEN);
    durRenderer.setDisplayChartValues(true);
    durRenderer.setChartValuesTextAlign(Paint.Align.CENTER);
    durRenderer.setChartValuesTextSize(15);

    XYSeriesRenderer speedRenderer = new XYSeriesRenderer();
    speedRenderer.setColor(Color.CYAN);
    speedRenderer.setDisplayChartValues(true);
    speedRenderer.setChartValuesTextAlign(Paint.Align.CENTER);
    speedRenderer.setChartValuesTextSize(15);

    XYMultipleSeriesRenderer mRender = new XYMultipleSeriesRenderer();
    mRender.setBarSpacing(1);
    mRender.addSeriesRenderer(durRenderer);
    mRender.addSeriesRenderer(speedRenderer);
    mRender.setChartTitle("Travel Time and Speed");
    mRender.setXTitle("Departure Time");
    mRender.setYTitle("Duration and Speed");
    mRender.setZoomButtonsVisible(true);
    mRender.setLabelsTextSize(20);
    mRender.setLegendTextSize(15);
    mRender.setChartTitleTextSize(28);
    mRender.setAxisTitleTextSize(25);
    mRender.setXAxisMin(trafficStatList.get(1).getHour());
    mRender.setXAxisMax(trafficStatList.size());

    for (int i = 0; i < timeLength; i++)
    {
        mRender.addTextLabel(i + 1, String.valueOf((int) trafficStatList.get(i).getHour() + ":" + (int) trafficStatList.get(i).getMinutes() ));
    }
    mRender.setXLabelsAlign(CENTER);
    mRender.setXLabels(0);

    // Getting a reference to LinearLayout of the MainActivity Layout
    LinearLayout chartContainer = (LinearLayout) findViewById(R.id.chart_container);

    // Creating a Time Chart
    mChart = (GraphicalView) ChartFactory.getBarChartView(getBaseContext(), data, mRender, BarChart.Type.DEFAULT);
    //return intent;
    mRender.setClickEnabled(true);
    mRender.setSelectableBuffer(10);

    mChart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SeriesSelection seriesSelection = mChart.getCurrentSeriesAndPoint();
            if (seriesSelection != null) {
                int seriesIndex = seriesSelection.getSeriesIndex();
                String selectedSeries = "Duration";
                if(seriesIndex==0)
                    selectedSeries = "Duration";
                else
                    selectedSeries = "Speed";
            }
        }
    });

    chartContainer.addView(mChart);
}
 
开发者ID:Routelandia,项目名称:routelandia-android,代码行数:79,代码来源:ListStat.java

示例5: getChartView

import org.achartengine.ChartFactory; //导入方法依赖的package包/类
public GraphicalView getChartView(Context context, String[] titles, List<double[]> values) {
    return ChartFactory.getBarChartView(context, buildBarDataset(titles, values), renderer,
            Type.STACKED);
}
 
开发者ID:CodePath-MAF,项目名称:AndroidClient,代码行数:5,代码来源:StackedBarChart.java

示例6: onCreate

import org.achartengine.ChartFactory; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	int[] y = { 100, 200, 300};
	String[] label = {"Ya","Tidak","Belum"};

	for (int x = 0; x < label.length; x++) {
		CategorySeries seri = new CategorySeries(label[x]);
	    series.add(seri);
	 
	}

	XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

			series.get(0).add("Bar " + (1 + 1), 100);
			series.get(1).add("Bar " + (2 + 2), 200);
			series.get(2).add("Bar " + (3 + 3), 300);
			
			series.get(0).add("Bar " + (1 + 1), 400);
			series.get(1).add("Bar " + (2 + 2), 500);
			series.get(2).add("Bar " + (3 + 3), 600);
			
			series.get(0).add("Bar " + (1 + 1), 700);
			series.get(1).add("Bar " + (2 + 2), 800);
			series.get(2).add("Bar " + (3 + 3), 900);
			dataset.addSeries(series.get(0).toXYSeries());
			dataset.addSeries(series.get(1).toXYSeries());
			dataset.addSeries(series.get(2).toXYSeries());
	


	LinearLayout ln = (LinearLayout) findViewById(R.id.chart);

	
	

	XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
	mRenderer.setChartTitle("Contoh Graph");
	mRenderer.setXTitle("X VALUES");
	mRenderer.setYTitle("Y VALUES");
	mRenderer.setAxesColor(Color.parseColor("#D7372F"));
	mRenderer.setLabelsColor(Color.parseColor("#000000"));
	
	mRenderer.setBackgroundColor(Color.parseColor("#FFFFFF"));

	mRenderer.setBarSpacing(1);

	mRenderer.setApplyBackgroundColor(true);
	mRenderer.setBackgroundColor(Color.WHITE);
	mRenderer.setMarginsColor(Color.WHITE);

	XYSeriesRenderer renderer = new XYSeriesRenderer();
	renderer.setColor(Color.parseColor("#D7372F"));
	renderer.setDisplayChartValues(true);
	renderer.setChartValuesSpacing(200);
	mRenderer.addSeriesRenderer(renderer);
	
	XYSeriesRenderer renderer2 = new XYSeriesRenderer();
	renderer2.setColor(Color.parseColor("#000675"));
	renderer2.setDisplayChartValues(true);

	mRenderer.addSeriesRenderer(renderer2);
	
	XYSeriesRenderer renderer3 = new XYSeriesRenderer();
	renderer3.setColor(Color.parseColor("#000000"));
	renderer3.setDisplayChartValues(true);
	
	mRenderer.addSeriesRenderer(renderer3);

	view = ChartFactory.getBarChartView(this, dataset, mRenderer,
			Type.DEFAULT);
	view.setBackgroundColor(Color.parseColor("#FFFFFF"));
	
	ln.addView(view);
}
 
开发者ID:mexanjuadha,项目名称:android_graph_example,代码行数:77,代码来源:MainActivity.java


注:本文中的org.achartengine.ChartFactory.getBarChartView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。