本文整理汇总了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);
}
示例2: getView
import org.achartengine.ChartFactory; //导入方法依赖的package包/类
public View getView(MainActivity Main) {
BuildChart(Main);
return ChartFactory.getBarChartView(Main,
buildBarDataset(titles, values), renderer, Type.DEFAULT);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}