本文整理汇总了Java中com.github.mikephil.charting.charts.BarChart.getAxisRight方法的典型用法代码示例。如果您正苦于以下问题:Java BarChart.getAxisRight方法的具体用法?Java BarChart.getAxisRight怎么用?Java BarChart.getAxisRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.BarChart
的用法示例。
在下文中一共展示了BarChart.getAxisRight方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHorizontalBarChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* Set the horizontal bar pattern
* @param barChart chart
* @param chartData horizontal bar chart data
* @param jobs string array of job titles
* @param typeface Typeface font
*/
public static void setHorizontalBarChart(BarChart barChart, final ChartData<?> chartData,
final String[] jobs, Typeface typeface) {
barChart.setDrawGridBackground(false);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//xAxis.setLabelCount(chartData.getEntryCount());
xAxis.setLabelCount(jobs.length);
xAxis.setTypeface(typeface);
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinimum(0f);
leftAxis.setGranularity(1f);
leftAxis.setDrawAxisLine(true);
leftAxis.setDrawGridLines(true);
YAxis axisRight = barChart.getAxisRight();
axisRight.setTypeface(typeface);
axisRight.setDrawAxisLine(true);
axisRight.setDrawGridLines(false);
axisRight.setGranularity(1f);
axisRight.setAxisMinimum(0f);
final Legend legend = barChart.getLegend();
legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
legend.setDrawInside(false);
legend.setFormSize(8f);
legend.setXEntrySpace(4f);
barChart.setData((BarData) chartData);
barChart.setFitBars(true);
barChart.animateY(DURATION_LONG);
xAxis.setValueFormatter(new HorizontalBarValueFormatter(jobs));
}
示例2: setVerticalBarChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* Set the vertical bar pattern
* @param barChart chart
* @param chartData pie chart data
* @param typeface Typeface font
*/
public static void setVerticalBarChart(Context context, BarChart barChart, ChartData<?> chartData,
Typeface typeface) {
// create a custom MarkerView (extend MarkerView) and specify the layout to use for it
ExperienceMarker marker = new ExperienceMarker(context, R.layout.marker_exp_age);
marker.setChartView(barChart); // For bounds control
barChart.setMarker(marker);
//fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
barChart.setDrawMarkers(false);
barChart.getDescription().setEnabled(false);
barChart.setDrawGridBackground(false);
barChart.setDrawBarShadow(false);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//Sets the number of labels for the x-axis (display all the x-axis values)
// xAxis.setLabelCount(chartData.getEntryCount());
xAxis.setTypeface(typeface);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setSpaceTop(20f);
leftAxis.setAxisMinimum(0f);
YAxis rightAxis = barChart.getAxisRight();
rightAxis.setTypeface(typeface);
rightAxis.setSpaceTop(20f);
rightAxis.setAxisMinimum(0f);
chartData.setValueTypeface(typeface);
barChart.setData((BarData) chartData);
barChart.setFitBars(true);
barChart.animateY(DURATION_SHORT);
}
示例3: initChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* initiliaze chart
*/
private void initChart() {
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDescriptionColor(Color.parseColor("#000000"));
XAxis xAxis = mChart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setSpaceBetweenLabels(0);
YAxisValueFormatter custom = new DataAxisFormatter("%");
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setValueFormatter(custom);
rightAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setDrawGridLines(true);
rightAxis.setDrawGridLines(false);
mChart.animateY(1000);
mChart.getLegend().setEnabled(true);
mChart.setVisibility(View.GONE);
}
示例4: setChartAverage
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* Needs calling chart.invalidate() afterwards
* @param chart
* @param data
* @param average
*/
private void setChartAverage(BarChart chart, DetailsData data, boolean average) {
YAxis axis = chart.getAxisRight();
if(axis.getLimitLines().size() > 0) {
//If line exists remove and make new one
//(can't simply change value, 3rd party limitation)
axis.getLimitLines().remove(0);
}
if(average) {
boolean mode = mPresenter.getMode();
LimitLine line = getChartLimitLine(data.getAverage(mode), data.getAverageLabel(mode));
axis.addLimitLine(line);
line.setEnabled(true);
}
}
示例5: initChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
private void initChart(BarChart chart) {
float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
chart.setDragEnabled(true);
chart.setScaleYEnabled(false);
chart.setScaleXEnabled(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setPinchZoom(false);
chart.setHighlightPerDragEnabled(false);
chart.setHighlightPerTapEnabled(false);
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setDrawValueAboveBar(false);
chart.getAxisLeft().setEnabled(false);
XAxis xAxis = chart.getXAxis();
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
xAxis.setDrawLabels(false);
xAxis.setDrawLimitLinesBehindData(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
YAxis yAxis = chart.getAxisRight();
yAxis.setDrawAxisLine(false);
yAxis.setStartAtZero(false);
yAxis.setSpaceTop(10f);
yAxis.setSpaceBottom(0f);
yAxis.setTextSize(10 * scaledDensity);
yAxis.setTextColor(ContextCompat.getColor(this, R.color.text));
chart.getLegend().setEnabled(false);
chart.setDescription(" ");
chart.setNoDataText("Can't see sh*t captain!");
Paint p = chart.getPaint(Chart.PAINT_INFO);
DisplayMetrics dm = getResources().getDisplayMetrics();
int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 18, dm); //TODO use styles
p.setTextSize(size);
p.setColor(ContextCompat.getColor(this, R.color.gray600));
p.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
}
示例6: initChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
private void initChart() {
barChart = (BarChart)findViewById(R.id.chart);
barChart.setBorderColor(getResources().getColor(R.color.primary_dark));
barChart.setDrawBarShadow(false);
barChart.setDrawValueAboveBar(true);
barChart.setDescription("Operations/second");
barChart.setMaxVisibleValueCount(20);
barChart.setPinchZoom(false);
barChart.setDrawGridBackground(false);
XAxis xl = barChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(true);
xl.setGridLineWidth(0.3f);
YAxis yl = barChart.getAxisLeft();
yl.setDrawAxisLine(true);
yl.setDrawGridLines(true);
yl.setGridLineWidth(0.3f);
YAxis yr = barChart.getAxisRight();
yr.setDrawAxisLine(true);
yr.setDrawGridLines(false);
Legend l = barChart.getLegend();
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setFormSize(8f);
l.setXEntrySpace(4f);
}
示例7: 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_barchart_sinus);
mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");
tvX = (TextView) findViewById(R.id.tvValueCount);
mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinimum(-2.5f);
leftAxis.setAxisMaximum(2.5f);
leftAxis.setGranularityEnabled(true);
leftAxis.setGranularity(0.1f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinimum(-2.5f);
rightAxis.setAxisMaximum(2.5f);
rightAxis.setGranularity(0.1f);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarX.setProgress(150); // set data
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
示例8: populateUserStatsChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* Show user stats graph
*/
private void populateUserStatsChart() {
final String[] userStatsChartXAxisLabel = getActivity().getResources().getStringArray(R.array.user_stats_x_axis_labels);
final BarChart chart = getActivity().findViewById(R.id.user_stats_chart);
chart.setTouchEnabled(false);
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(1);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new IAxisValueFormatter() {
/**
* Format the value
* @param value - value to fit to the axis
* @param axis - the axis to fit to
* @return Returns the formatted value
*/
@Override
public String getFormattedValue(float value, AxisBase axis) {
int v = (int) value;
return userStatsChartXAxisLabel[v];
}
});
xAxis.setDrawGridLines(false);
xAxis.setTextSize(11f);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setEnabled(false);
chart.getAxisLeft().setGranularity(1);
chart.getDescription().setEnabled(false);
if (mUser != null) {
int[] colors = getActivity().getResources().getIntArray(R.array.user_stats_chart_colors);
List<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(0f, mUser.getPlantsAdded()));
entries.add(new BarEntry(1f, mUser.getPlantsDeleted()));
entries.add(new BarEntry(2f, mUser.getWaterCount()));
entries.add(new BarEntry(3f, mUser.getMeasureCount()));
entries.add(new BarEntry(4f, mUser.getPhotoCount()));
BarDataSet barDataSet = new BarDataSet(entries, "Plant Operations");
barDataSet.setColors(ColorTemplate.createColors(colors));
barDataSet.setValueTextSize(11f);
BarData data = new BarData(barDataSet);
data.setBarWidth(0.9f); // set custom bar width
chart.setData(data);
chart.invalidate(); // refresh
}
}
示例9: initCharts
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
private void initCharts(BarChart mChart) {
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
leftAxis.setLabelCount(6, false);
// leftAxis.setAxisMinimum(-2.5f);
// leftAxis.setAxisMaximum(2.5f);
leftAxis.setGranularityEnabled(true);
leftAxis.setGranularity(0.1f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
rightAxis.setLabelCount(6, false);
// rightAxis.setAxisMinimum(-2.5f);
// rightAxis.setAxisMaximum(2.5f);
rightAxis.setGranularity(0.1f);
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setForm(Legend.LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
示例10: 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_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);
YAxisValueFormatter custom = new MyYAxisValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
// l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
// l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
setData(12, 50);
// setting data
mSeekBarY.setProgress(50);
mSeekBarX.setProgress(12);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
// mChart.setDrawLegend(false);
}
示例11: 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_barchart_sinus);
mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(),"othersine.txt");
tvX = (TextView) findViewById(R.id.tvValueCount);
mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinValue(-2.5f);
leftAxis.setAxisMaxValue(2.5f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinValue(-2.5f);
rightAxis.setAxisMaxValue(2.5f);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarX.setProgress(150); // set data
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
示例12: initializeViews
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
private void initializeViews() {
titleTextView = (TextView) findViewById(R.id.view_chart_bar_title);
titleTextView.setText(titleText);
titleTextView.setTextColor(titleTextColor);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));
expand = (ImageView) findViewById(R.id.view_chart_line_expand);
if (expandTintColor != 0) {
Drawable drawable = expand.getDrawable();
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, expandTintColor);
expand.setImageDrawable(drawable);
}
chart = (BarChart) findViewById(R.id.view_chart_bar);
chart.getLegend().setEnabled(false);
chart.setDescription("");
chart.setDrawBorders(false);
chart.setDrawValueAboveBar(false);
chart.setDrawGridBackground(false);
chart.setDrawBarShadow(false);
chart.setDrawHighlightArrow(false);
chart.setPinchZoom(false);
chart.setExtraLeftOffset(0);
chart.setExtraRightOffset(0);
chart.setExtraBottomOffset(8);
chart.setExtraTopOffset(0);
chart.setTouchEnabled(true);
chart.setDragEnabled(true);
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawAxisLine(false);
xAxis.setYOffset(16);
xAxis.setDrawGridLines(false);
xAxis.setLabelsToSkip(0);
xAxis.setTextSize(chartXAxisTextSize);
xAxis.setTextColor(chartXAxisTextColor);
xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL));
YAxis yAxisLeft = chart.getAxisLeft();
yAxisLeft.setDrawAxisLine(false);
yAxisLeft.setDrawGridLines(false);
yAxisLeft.setDrawZeroLine(false);
yAxisLeft.setDrawLabels(false);
YAxis yAxisRight = chart.getAxisRight();
yAxisRight.setDrawAxisLine(false);
yAxisRight.setDrawGridLines(false);
yAxisRight.setDrawZeroLine(false);
yAxisRight.setDrawLabels(false);
}
示例13: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scoreboard);
dbInit(getIntent());
sparkAddressMap = new HashMap<String, String>();
sparkAddressMap.put("BlackMage", "53ff70065075535143191087");
sparkAddressMap.put("WhiteMage", "50ff6e065067545631270587");
sparkAddressMap.put("GreenMage", "48ff70065067555028111587");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setOnChartGestureListener(this);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// Dario flag changes
mChart.setDragEnabled(false);
mChart.setScaleEnabled(false);
// Set max on the chart to 10 for now, should never go above 3 on demo
mChart.setMaxVisibleValueCount(10);
// Scaling can now only be done on the x and y-axis separately
mChart.setPinchZoom(false);
// Disable background
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
intFormat = new MyValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(intFormat);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
setData();
Legend l = mChart.getLegend();
l.setEnabled(false);
/*** Begin Repeating Alarm Setup ***/
int pollFrequencySeconds = 5;
Context context = getApplicationContext();
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra("myGlass", myGlass);
// Log.d(TAG, "Input to alarm: " + myGlass);
intent.putExtra("myAddr", sparkAddressMap.get(myGlass));
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
1000 * pollFrequencySeconds,
1000 * pollFrequencySeconds,
alarmIntent);
Toast.makeText(this, "Alarm Set", Toast.LENGTH_SHORT).show();
/*** Begin UI Update Listener ***/
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
setDataFromJSON(intent.getStringExtra(PollGameStatusService.SCORE_KEY));
}
};
}
示例14: onCreateView
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if(view == null) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_measurement_spectrum, container, false);
BarChart sChart = (BarChart) view.findViewById(R.id.spectrumChart);
sChart.setDrawBarShadow(false);
sChart.setDescription("");
sChart.getLegend().setEnabled(false);
sChart.setTouchEnabled(false);
sChart.setPinchZoom(false);
sChart.setDrawGridBackground(false);
sChart.setMaxVisibleValueCount(0);
sChart.setHorizontalScrollBarEnabled(false);
sChart.setVerticalScrollBarEnabled(false);
sChart.setNoDataTextDescription(getText(R.string.no_data_text_description).toString());
// XAxis parameters:
XAxis xls = sChart.getXAxis();
xls.setPosition(XAxis.XAxisPosition.BOTTOM);
xls.setDrawAxisLine(true);
xls.setDrawGridLines(false);
xls.setDrawLabels(true);
xls.setTextColor(Color.WHITE);
xls.setAvoidFirstLastClipping(false);
// YAxis parameters (left): main axis for dB values representation
YAxis yls = sChart.getAxisLeft();
yls.setDrawAxisLine(true);
yls.setDrawGridLines(true);
yls.setAxisMaxValue(100.f);
yls.setAxisMinValue(0f);
yls.setTextColor(Color.WHITE);
yls.setGridColor(Color.WHITE);
yls.setSpaceBottom(0);
yls.setSpaceTop(0);
yls.setValueFormatter(new SPLValueFormatter());
// YAxis parameters (right): no axis, hide all
YAxis yrs = sChart.getAxisRight();
yrs.setEnabled(false);
}
return view;
}