本文整理汇总了Java中com.github.mikephil.charting.components.XAxis.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Java XAxis.setPosition方法的具体用法?Java XAxis.setPosition怎么用?Java XAxis.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.XAxis
的用法示例。
在下文中一共展示了XAxis.setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dataSortedOnDay
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnDay(int year, int month, int dayOfMonth) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(-0.5f);
xaxis.setAxisMaximum(23.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.hour_of_day_string));
String path = String.format("/cow_data/%s/%d/%d/%d", cowId, year, month, dayOfMonth);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例2: dataSortedOnYear
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnYear(int year) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(0.5f);
xaxis.setAxisMaximum(12.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.month_of_year_string));
String path = String.format("/cow_data/%s/%d", cowId, year);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例3: setupXAxis
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupXAxis(BarLineChartBase chart, IAxisValueFormatter formatter) {
XAxis x = chart.getXAxis();
x.setGranularity(1.0f);
x.setDrawGridLines(false);
x.setPosition(XAxis.XAxisPosition.BOTTOM);
x.setDrawAxisLine(false);
x.setCenterAxisLabels(true);
x.setAxisMinimum(2.0f);
x.setAxisMaximum(5.0f);
x.setValueFormatter(formatter);
}
示例4: setHorizontalBarChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的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));
}
示例5: onCreateView
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
mChart.getDescription().setEnabled(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv);
mChart.setDrawGridBackground(false);
mChart.setData(generateScatterData(6, 10000, 200));
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(tf);
rightAxis.setDrawGridLines(false);
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(tf);
l.setFormSize(14f);
l.setTextSize(9f);
// increase the space between legend & bottom and legend & content
l.setYOffset(13f);
mChart.setExtraBottomOffset(16f);
return v;
}
示例6: dataSortedOnMonth
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnMonth(int year, int month) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
int iMonth = month - 1; // 1 (months begin with 0)
// Create a calendar object and set year and month
Calendar mycal = new GregorianCalendar(year, iMonth, 1);
// Get the number of days in that month
int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(0.5f);
xaxis.setAxisMaximum(daysInMonth + 0.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.day_of_month_string));
String path = String.format("/cow_data/%s/%d/%d", cowId, year, month);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例7: init
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
setDrawBarShadow(false);
setDrawValueAboveBar(true);
getDescription().setEnabled(false);
setMaxVisibleValueCount(60);
setDrawGridBackground(false);
XAxis xl = getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(false);
xl.setGranularity(10f);
xl.setTextColor(Color.GRAY);
YAxis yl = getAxisLeft();
yl.setDrawAxisLine(false);
yl.setDrawGridLines(false);
yl.setDrawLabels(false);
yl.setAxisMinimum(0f);
yl.setTextColor(Color.GRAY);
YAxis yr = getAxisRight();
yr.setDrawAxisLine(true);
yr.setDrawGridLines(false);
yr.setAxisMinimum(0f);
yl.setTextColor(Color.GRAY);
setFitBars(true);
animateY(2500);
Legend l = getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setFormSize(8f);
l.setXEntrySpace(4f);
}
示例8: setup
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.getDescription().setEnabled(false);
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.DKGRAY);
leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.DKGRAY);
mChart.getAxisRight().setEnabled(false);
}
}
示例9: getFormattedLineChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
* Formats a line chart in a standardized manner
* @param c App context
* @param chart LineChart to format
* @param listener Listener to attach to chart
* @param xLabels Labels to use for the x-axis
* @param valueFormatter True if large value formatter should be used
* @param skip Number of values to skip
* @param legend True if show legend, false if hide legend
* @return Formatted linechart
*/
public static LineChart getFormattedLineChart(Context c, LineChart chart, OnChartValueSelectedListener listener, List<String> xLabels, boolean valueFormatter, int skip, boolean legend) {
Legend cLegend = chart.getLegend();
cLegend.setEnabled(legend);
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(skip);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new XAxisLabelFormatter(xLabels));
YAxis yAxisRight = chart.getAxisRight();
yAxisRight.setEnabled(false);
YAxis yAxisLeft = chart.getAxisLeft();
if (valueFormatter) {
yAxisLeft.setValueFormatter(new LargeNumberAxisFormatter(c));
}
if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
int textColorNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
cLegend.setTextColor(textColorNoir);
xAxis.setTextColor(textColorNoir);
yAxisLeft.setTextColor(textColorNoir);
}
chart.setDoubleTapToZoomEnabled(false);
chart.setDescription(EMPTY_CHART_DESCRIPTION);
chart.setDragEnabled(true);
chart.setScaleYEnabled(false);
chart.setDrawGridBackground(false);
chart.setOnChartValueSelectedListener(listener);
return chart;
}
示例10: initChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的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));
}
示例11: initChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void initChart() {
barChart.setDrawBarShadow(false);
barChart.setDrawValueAboveBar(true);
barChart.getDescription().setEnabled(false);
barChart.setPinchZoom(false);
barChart.setMaxVisibleValueCount(60);
barChart.getLegend().setEnabled(false);
barChart.setDrawGridBackground(false);
barChart.getAxisRight().setEnabled(false);
barChart.setScaleYEnabled(false);
dayAxisValueFormatter = new DayAxisValueFormatter();
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setLabelRotationAngle(270);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
xAxis.setTextColor(getOutlayTheme().secondaryTextColor);
xAxis.setValueFormatter(dayAxisValueFormatter);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setValueFormatter(new AmountValueFormatter());
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setTextColor(getOutlayTheme().secondaryTextColor);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinimum(0f);
}
示例12: onCreate
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_scrollview);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setLabelsToSkip(0);
xAxis.setDrawGridLines(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getLegend().setEnabled(false);
setData(10);
}
示例13: getView
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
BarData data = getItem(position);
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.list_item_barchart, null);
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
data.setValueTypeface(mTfLight);
data.setValueTextColor(Color.BLACK);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTfLight);
xAxis.setDrawGridLines(false);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(15f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(5, false);
rightAxis.setSpaceTop(15f);
// set data
holder.chart.setData(data);
holder.chart.setFitBars(true);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(700);
return convertView;
}
示例14: onCreate
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_linechart_time);
tvX = (TextView) findViewById(R.id.tvXMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setProgress(100);
tvX.setText("100");
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
mChart.setDragDecelerationFrictionCoef(0.9f);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
mChart.setHighlightPerDragEnabled(true);
// set an alternative background color
mChart.setBackgroundColor(Color.WHITE);
mChart.setViewPortOffsets(0f, 0f, 0f, 0f);
// add data
setData(100, 30);
mChart.invalidate();
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE);
xAxis.setTypeface(mTfLight);
xAxis.setTextSize(10f);
xAxis.setTextColor(Color.WHITE);
xAxis.setDrawAxisLine(false);
xAxis.setDrawGridLines(true);
xAxis.setTextColor(Color.rgb(255, 192, 56));
xAxis.setCenterAxisLabels(true);
xAxis.setGranularity(1f); // one hour
xAxis.setValueFormatter(new IAxisValueFormatter() {
private SimpleDateFormat mFormat = new SimpleDateFormat("dd MMM HH:mm");
@Override
public String getFormattedValue(float value, AxisBase axis) {
long millis = TimeUnit.HOURS.toMillis((long) value);
return mFormat.format(new Date(millis));
}
});
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
leftAxis.setTypeface(mTfLight);
leftAxis.setTextColor(ColorTemplate.getHoloBlue());
leftAxis.setDrawGridLines(true);
leftAxis.setGranularityEnabled(true);
leftAxis.setAxisMinimum(0f);
leftAxis.setAxisMaximum(170f);
leftAxis.setYOffset(-9f);
leftAxis.setTextColor(Color.rgb(255, 192, 56));
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
}
示例15: onCreate
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_bubblechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BubbleChart) findViewById(R.id.chart1);
mChart.getDescription().setEnabled(false);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setMaxVisibleValueCount(200);
mChart.setPinchZoom(true);
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(50);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setTypeface(mTfLight);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(mTfLight);
yl.setSpaceTop(30f);
yl.setSpaceBottom(30f);
yl.setDrawZeroLine(false);
mChart.getAxisRight().setEnabled(false);
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setTypeface(mTfLight);
}