本文整理汇总了Java中com.github.mikephil.charting.charts.BarChart类的典型用法代码示例。如果您正苦于以下问题:Java BarChart类的具体用法?Java BarChart怎么用?Java BarChart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BarChart类属于com.github.mikephil.charting.charts包,在下文中一共展示了BarChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getView
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
/**
* Returns the view to display bar chart
*/
public View getView(final Activity activity, View rootView) {
this.activity = activity;
View view = null;
LayoutInflater inflater;
Context context = activity.getApplicationContext();
onOperationIssueChange(rootView);
if (context != null) {
if (view == null && context != null && activity != null) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.statistics_view, null);
}
BarChart barChart = (BarChart) view.findViewById(R.id.chart);
UtilsRG.info("chart init: " + barChart);
initBarChartConfiguration(activity, barChart);
initBarChartDataAsync(activity, barChart);
initInValidGoNoGoGameLineChart(activity, view);
addDataToInValidGoNoGoGameLineChart(activity);
}
return view;
}
示例2: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timevis_layout);
barchart = (BarChart) findViewById(R.id.barchart);
Intent intent = getIntent();
String ot = intent.getExtras().getString("ot");
String pt = intent.getExtras().getString("pt");
String lt = intent.getExtras().getString("lt");
String pert = intent.getExtras().getString("pert");
Float otf = Float.valueOf(ot);
Float ptf = Float.valueOf(pt);
Float ltf = Float.valueOf(lt);
Float pertf = Float.valueOf(pert);
List<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(0f, otf.floatValue()));
entries.add(new BarEntry(1f, ptf.floatValue()));
entries.add(new BarEntry(2f, ltf.floatValue()));
entries.add(new BarEntry(3f, pertf.floatValue()));
BarDataSet set = new BarDataSet(entries, "Time Visualization");
BarData data = new BarData(set);
data.setBarWidth(0.9f); // set custom bar width
barchart.setData(data);
barchart.setFitBars(true); // make the x-axis fit exactly all bars
barchart.invalidate();
}
示例3: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_realm_wiki);
lineChart = (LineChart) findViewById(R.id.lineChart);
barChart = (BarChart) findViewById(R.id.barChart);
setup(lineChart);
setup(barChart);
lineChart.setExtraBottomOffset(5f);
barChart.setExtraBottomOffset(5f);
lineChart.getAxisLeft().setDrawGridLines(false);
lineChart.getXAxis().setDrawGridLines(false);
lineChart.getXAxis().setLabelCount(5);
lineChart.getXAxis().setGranularity(1f);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getXAxis().setDrawGridLines(false);
barChart.getXAxis().setLabelCount(5);
barChart.getXAxis().setGranularity(1f);
}
示例4: onCreateViewHolder
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
default:
case Model.TEXT_TYPE:
return new ViewHolderText(new TextView(parent.getContext()));
case Model.IMAGE_TYPE:
return new ViewHolderImage(new ImageView(parent.getContext()));
case Model.TWEET_TYPE:
return new ViewHolderTweet(LayoutInflater.from(parent.getContext()).inflate(R.layout.tweet_card, parent, false));
case Model.COMMENT_TYPE:
return new ViewHolderText(new TextView(parent.getContext()));
case Model.GRAPH_TYPE_BARS:
return new ViewHolderChart<>(new HorizontalBarChart(parent.getContext()));
case Model.GRAPH_TYPE_COLUMNS:
return new ViewHolderChart<>(new BarChart(parent.getContext()));
}
}
示例5: getModelType
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
static int getModelType(Chart chart) {
if (chart == null) {
return Model.UNKNOWN_TYPE;
} else {
String type = chart.getTag().toString();
if (HorizontalBarChart.class.getSimpleName().equals(type)) {
Log.d(TAG, "HorizontalBarChart");
return Model.GRAPH_TYPE_BARS;
} else if (BarChart.class.getSimpleName().equals(type)) {
Log.d(TAG, "BarChart");
return Model.GRAPH_TYPE_COLUMNS;
} else {
return Model.UNKNOWN_TYPE;
}
}
}
示例6: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_realm_wiki);
lineChart = (LineChart) findViewById(R.id.lineChart);
barChart = (BarChart) findViewById(R.id.barChart);
setup(lineChart);
setup(barChart);
lineChart.setExtraBottomOffset(5f);
barChart.setExtraBottomOffset(5f);
lineChart.getAxisLeft().setDrawGridLines(false);
lineChart.getXAxis().setDrawGridLines(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getXAxis().setDrawGridLines(false);
}
示例7: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
// enable for testing
if (true) {
// demoBarChart();
demoBarChartStacked();
} else {
// hide UI component
BarChart barChart = (BarChart) findViewById(R.id.chart);
barChart.setVisibility(View.INVISIBLE);
}
// show device configuration
Toast.makeText(getApplicationContext(),
getSizeName(getApplicationContext()) + " " + getResources().getConfiguration(),
Toast.LENGTH_LONG).show();
}
示例8: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chart);
barChart = (BarChart) findViewById(R.id.barChart);
horizontalBarChart = (HorizontalBarChart) findViewById(R.id.horizontalChart);
Bundle extras = getIntent().getExtras();
chartDataName = extras.getStringArrayList(keyName);
chartDataValue = extras.getIntegerArrayList(keyValue);
title = extras.getString(keyTitle);
setTitle(title);
populateChart();
}
示例9: StatisticsCache
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
public StatisticsCache(AppCompatActivity activity)
{
this.activity = activity;
titleTextView = (TextView) activity.findViewById(R.id.textview_stats_title);
chart = (BarChart) activity.findViewById(R.id.chart);
totalTextView = (TextView) activity.findViewById(R.id.textview_stats_total);
unitsTextView = (TextView) activity.findViewById(R.id.textview_stats_currency);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
String defaultCurrency = activity.getResources().getString(R.string.currency);
currency = prefs.getString(SettingsKeys.CURRENCY, defaultCurrency);
unitsTextView.setText(currency);
rangeFromTextView = (TextView) activity.findViewById(R.id.textview_stats_range_from);
rangeToTextView = (TextView) activity.findViewById(R.id.textview_stats_range_to);
groupBySpinner = (Spinner) activity.findViewById(R.id.spinner_stats_group_by);
valuesSpinner = (Spinner) activity.findViewById(R.id.spinner_stats_values);
datePattern = activity.getResources().getString(R.string.date_short_pattern);
dateLanguage = activity.getResources().getString(R.string.language);
numberFormat = activity.getResources().getString(R.string.number_format_2_decimals);
}
示例10: insertChartSample
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
/**
* Procedure to add last DetailsData sample to chart.
* @param data
* @param chart
*/
private void insertChartSample(DetailsData data, BarChart chart, @Nullable Beacon beacon) {
data.insertAndUpdate(beacon);
BarData barData = chart.getData();
BarDataSet set = barData.getDataSetByIndex(0);
if(set.getEntryCount() == mPresenter.getSamplesCount()) {
barData.removeXValue(0);
set.removeEntry(0);
for (Entry entry : set.getYVals()) {
entry.setXIndex(entry.getXIndex() - 1);
}
}
barData.addXValue(" ");
BarEntry newEntry = new BarEntry(
data.getCurrentValue(mPresenter.getMode()),
set.getEntryCount());
barData.addEntry(newEntry, 0);
setChartRange(chart, data, mPresenter.getAutoscale());
setChartAverage(chart, data, mPresenter.getAverage());
chart.notifyDataSetChanged();
chart.invalidate();
}
示例11: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
simpleTrialButton = (Button) findViewById(R.id.simple);
complexTrialButton = (Button) findViewById(R.id.complex);
resultsLabel = (TextView) findViewById(R.id.resultsLabel);
resultsContainer = (ScrollView) findViewById(R.id.resultsContainer);
resultsTextView = (TextView) findViewById(R.id.results);
progressBar = (ProgressBar) findViewById(R.id.progress);
progressBar.setIndeterminate(true);
chartView = (BarChart) findViewById(R.id.chart);
if (savedInstanceState != null) {
runningTests = savedInstanceState.getBoolean(STATE_RUNNING_TESTS);
runningTestName = savedInstanceState.getString(STATE_TEST_NAME);
chartEntrySets = (LinkedHashMap<String, ArrayList<BarEntry>>) savedInstanceState.getSerializable(STATE_MAPDATA);
setBusyUI(runningTests, runningTestName);
if (!runningTests && (chartEntrySets.size() > 0)) {
// graph existing data
initChart();
}
}
}
示例12: initViews
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
/**
* Initialize all needed views.
*/
private void initViews() {
// get views for overview
llOverviewWrapper = (LinearLayout) findViewById(R.id.overview_wrapper);
tvOverviewParticipants = (TextView) findViewById(R.id.tv_overview_participants);
tvOverviewPassed = (TextView) findViewById(R.id.tv_overview_passed);
tvOverviewAverage = (TextView) findViewById(R.id.tv_overview_average);
barChart = (BarChart) findViewById(R.id.bar_chart);
tvOverviewNotPossible = (TextView) findViewById(R.id.tv_overview_not_possible);
tvOverviewNotPossible.setText(Html.fromHtml(getString(R.string.overview_not_possible, FaqDataProvider.GO_TO_WHY_NO_GRADING)));
tvOverviewNotPossible.setMovementMethod(LinkMovementMethod.getInstance());
llRootView = (LinearLayout) findViewById(R.id.ll_root_view);
tvCustomGradeEntry = (TextView) findViewById(R.id.tv_custom_grade_entry);
initPullToRefresh();
}
示例13: BarChartCustom
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
public BarChartCustom(BarChart graphical, ArrayList<BarEntry> entries, String entriesLegend, ArrayList<String> labels, String chartDecription)
{
this.entries = entries;
this.chart = graphical;
this.dataset = new BarDataSet(entries, entriesLegend);
this.data = new BarData(labels, this.dataset);
this.colors = new ArrayList<>();
this.yLeftAxis = chart.getAxisLeft();
this.yRightAxis = chart.getAxisRight();
this.xAxis = chart.getXAxis();
chart.setTouchEnabled(false);
this.average = new LimitLine(getAverage(), String.format("%1$s : %2$.2f", "Moyenne", getAverage()));
this.average.setTextSize(10);
this.average.setLineColor(Color.RED);
this.average.setLineWidth(1.5f);
this.yLeftAxis.addLimitLine(average);
this.average.setEnabled(false);
this.legend = chart.getLegend();
if(chartDecription!= null)
chart.setDescription(chartDecription);
else chart.setDescription("");
setDefaultChart();
setDefaultLegend();
setDefaultAxes();
}
示例14: onCreateView
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//return buildChart();
mLayout = (LinearLayout) inflater.inflate(R.layout.chart_bar_fragment, container, false);
mChart = (BarChart) mLayout.findViewById(R.id.chartBar);
mChart.setOnChartValueSelectedListener(this);
mChart.setDescription("");
// mChart.setDrawBorders(true);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
return mLayout;
}
示例15: onCreateView
import com.github.mikephil.charting.charts.BarChart; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.graph_reports, container,
false);
initializeFields(rootView);
setEventListeners();
lineChart = new LineChart(context);
barChart = new BarChart(context);
((MainActivity) activity).onSectionAttached("Graphs");
return rootView;
}