當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。