本文整理汇总了Java中com.github.mikephil.charting.components.YAxis类的典型用法代码示例。如果您正苦于以下问题:Java YAxis类的具体用法?Java YAxis怎么用?Java YAxis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
YAxis类属于com.github.mikephil.charting.components包,在下文中一共展示了YAxis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareInitData
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
private LineDataSet prepareInitData(@NonNull LineChart chart, @NonNull List<Entry> entries) {
final LineDataSet set = new LineDataSet(entries, "Accuracy");
set.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
set.setLineWidth(2F);
set.setDrawCircleHole(false);
set.setDrawCircles(false);
set.setHighlightEnabled(false);
set.setDrawFilled(true);
final LineData group = new LineData(set);
group.setDrawValues(false);
chart.setData(group);
return set;
}
示例2: initChart
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* Initialize the non-data aspects of the line chart
*/
private void initChart(){
//Initial line Chart for visualization of statistic
lineChart = (LineChart) findViewById(R.id.LineChart);
lineChart.setDragEnabled(true);
lineChart.setScaleEnabled(false);
lineChart.getAxisRight().setEnabled(false);
lineChart.getDescription().setEnabled(false);
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setAxisMaximum(100f);
leftAxis.setAxisMinimum(0.0f);
leftAxis.enableGridDashedLine(10f, 10f, 0f);
leftAxis.setDrawLimitLinesBehindData(true);
}
示例3: YAxisRenderer
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
public YAxisRenderer(ViewPortHandler viewPortHandler, YAxis yAxis, Transformer trans) {
super(viewPortHandler, trans, yAxis);
this.mYAxis = yAxis;
if(mViewPortHandler != null) {
mAxisLabelPaint.setColor(Color.BLACK);
mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f));
mZeroLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mZeroLinePaint.setColor(Color.GRAY);
mZeroLinePaint.setStrokeWidth(1f);
mZeroLinePaint.setStyle(Paint.Style.STROKE);
}
}
示例4: getMinimumDistance
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* Returns the minimum distance from a touch value (in pixels) to the
* closest value (in pixels) that is displayed in the chart.
*
* @param closestValues
* @param pos
* @param axis
* @return
*/
protected float getMinimumDistance(List<Highlight> closestValues, float pos, YAxis.AxisDependency axis) {
float distance = Float.MAX_VALUE;
for (int i = 0; i < closestValues.size(); i++) {
Highlight high = closestValues.get(i);
if (high.getAxis() == axis) {
float tempDistance = Math.abs(getHighlightPos(high) - pos);
if (tempDistance < distance) {
distance = tempDistance;
}
}
}
return distance;
}
示例5: getClosestHighlightByPixel
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* Returns the Highlight of the DataSet that contains the closest value on the
* y-axis.
*
* @param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by
* rounding up an down)
* @param x
* @param y
* @param axis the closest axis
* @param minSelectionDistance
* @return
*/
public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
YAxis.AxisDependency axis, float minSelectionDistance) {
Highlight closest = null;
float distance = minSelectionDistance;
for (int i = 0; i < closestValues.size(); i++) {
Highlight high = closestValues.get(i);
if (axis == null || high.getAxis() == axis) {
float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
if (cDistance < distance) {
closest = high;
distance = cDistance;
}
}
}
return closest;
}
示例6: generateLineData
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
private LineData generateLineData() {
LineData d = new LineData();
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int index = 0; index < itemcount; index++)
entries.add(new Entry(index + 0.5f, getRandom(15, 5)));
LineDataSet set = new LineDataSet(entries, "Line DataSet");
set.setColor(Color.rgb(240, 238, 70));
set.setLineWidth(2.5f);
set.setCircleColor(Color.rgb(240, 238, 70));
set.setCircleRadius(5f);
set.setFillColor(Color.rgb(240, 238, 70));
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setDrawValues(true);
set.setValueTextSize(10f);
set.setValueTextColor(Color.rgb(240, 238, 70));
set.setAxisDependency(YAxis.AxisDependency.LEFT);
d.addDataSet(set);
return d;
}
示例7: updateTargetArea
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
private void updateTargetArea() {
YAxis leftAxis = mPlot.getAxisLeft();
leftAxis.removeAllLimitLines();
LimitLine limitLineMax = new LimitLine(
GLUCOSE_TARGET_MAX
);
limitLineMax.setLineColor(Color.TRANSPARENT);
leftAxis.addLimitLine(limitLineMax);
LimitLine limitLineMin = new LimitLine(
GLUCOSE_TARGET_MIN,
getResources().getString(R.string.pref_glucose_target_area)
);
limitLineMin.setTextSize(10f);
limitLineMin.setLineColor(Color.argb(60, 100, 100, 120));
limitLineMin.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
leftAxis.addLimitLine(limitLineMin);
}
示例8: createSet
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
private LineDataSet createSet(String label) {
LineDataSet set = new LineDataSet(null, label);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
int color;
if (label.equals(pm1Label)) {
color = Color.BLUE;
} else if (label.equals(pm25Label)) {
color = Color.RED;
} else {
color = Color.BLACK;
}
set.setColor(color);
set.setLineWidth(2f);
set.setDrawValues(false);
set.setDrawCircles(false);
set.setMode(LineDataSet.Mode.LINEAR);
return set;
}
示例9: initInValidGoNoGoGameLineChart
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
private void initInValidGoNoGoGameLineChart(Activity activity, View view) {
inValidGoNoGoGamesLineChart = (LineChart) view.findViewById(R.id.line_chart_invalid_gonogogames);
inValidGoNoGoGamesLineChart.setDescription("");
String noData = activity.getResources().getString(R.string.no_failures_to_display);
inValidGoNoGoGamesLineChart.setNoDataText(noData);
inValidGoNoGoGamesLineChart.setTouchEnabled(false);
inValidGoNoGoGamesLineChart.setDragEnabled(true);
inValidGoNoGoGamesLineChart.setScaleEnabled(true);
inValidGoNoGoGamesLineChart.setPinchZoom(true);
inValidGoNoGoGamesLineChart.setBackgroundColor(Color.WHITE);
inValidGoNoGoGamesLineChart.setDrawGridBackground(false);
YAxis leftAxis = inValidGoNoGoGamesLineChart.getAxisLeft();
leftAxis.setAxisMinValue(0);
YAxis righAxis = inValidGoNoGoGamesLineChart.getAxisRight();
if (righAxis != null)
righAxis.setEnabled(false);
}
示例10: moveViewToAnimated
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* This will move the left side of the current viewport to the specified x-position
* and center the viewport to the specified y-position animated.
* This also refreshes the chart by calling invalidate().
*
* @param xIndex
* @param yValue
* @param axis
* @param duration the duration of the animation in milliseconds
*/
@TargetApi(11)
public void moveViewToAnimated(float xIndex, float yValue, YAxis.AxisDependency axis, long duration) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis);
float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY();
Runnable job = new AnimatedMoveViewJob(mViewPortHandler, xIndex, yValue + valsInView / 2f,
getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration);
addViewportJob(job);
} else {
Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11");
}
}
示例11: generateOrderBarData
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
private BarData generateOrderBarData(List<MarketHistory> historyEntries) {
SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());
int size = historyEntries.size();
List<BarEntry> entries = new ArrayList<>(size);
List<String> xAxis = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
MarketHistory history = historyEntries.get(i);
Date recordDate = new Date(history.getRecordDate());
xAxis.add(format.format(recordDate));
entries.add(new BarEntry((float) history.getOrderCount(), i));
}
BarDataSet set = new BarDataSet(entries, "Order Count");
set.setColor(Color.parseColor("#99FF99"));
// set.setValueTextSize(0f);
set.setDrawValues(false);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
return new BarData(xAxis, set);
}
示例12: setup
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* 设置字体
*
* @param chart
*/
protected void setup(Chart<?> chart) {
mTy = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setPinchZoom(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTy);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.WHITE);
XAxis xAxis = mChart.getXAxis();
xAxis.setLabelRotationAngle(-50);//设置x轴字体显示角度
xAxis.setTypeface(mTy);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
}
}
示例13: generateLineData
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* 曲线
*/
private LineData generateLineData() {
LineData lineData = new LineData();
ArrayList<Entry> entries = new ArrayList<>();
for (int index = 0; index < items.size(); index++) {
entries.add(new Entry(index + 1f, (float) items.get(index).sub_data.getData()));
}
LineDataSet lineDataSet = new LineDataSet(entries, "对比数据");
lineDataSet.setValues(entries);
lineDataSet.setDrawValues(false);//是否在线上显示值
lineDataSet.setColor(ContextCompat.getColor(mContext, R.color.co3));
lineDataSet.setLineWidth(2.5f);
lineDataSet.setCircleColor(ContextCompat.getColor(mContext, R.color.co3));
lineDataSet.setCircleRadius(5f);
lineDataSet.setDrawCircles(false);
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);//设置线条类型
//set.setDrawHorizontalHighlightIndicator(false);//隐藏选中线
//set.setDrawVerticalHighlightIndicator(false);//隐藏选中线条
lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
lineDataSet.setHighlightEnabled(false);
lineData.setHighlightEnabled(false);
lineData.addDataSet(lineDataSet);
return lineData;
}
示例14: centerViewToAnimated
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
/**
* This will move the center of the current viewport to the specified
* x-value and y-value animated.
*
* @param xIndex
* @param yValue
* @param axis
* @param duration the duration of the animation in milliseconds
*/
@TargetApi(11)
public void centerViewToAnimated(float xIndex, float yValue, YAxis.AxisDependency axis, long duration) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis);
float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY();
float xsInView = getXAxis().getValues().size() / mViewPortHandler.getScaleX();
Runnable job = new AnimatedMoveViewJob(mViewPortHandler,
xIndex - xsInView / 2f, yValue + valsInView / 2f,
getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration);
addViewportJob(job);
} else {
Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11");
}
}
示例15: calcMinMax
import com.github.mikephil.charting.components.YAxis; //导入依赖的package包/类
@Override
protected void calcMinMax() {
if (mAutoScaleMinMaxEnabled)
mData.calcMinMax();
if (mFitBars) {
mXAxis.calculate(mData.getXMin() - mData.getBarWidth() / 2f, mData.getXMax() + mData.getBarWidth() / 2f);
} else {
mXAxis.calculate(mData.getXMin(), mData.getXMax());
}
// calculate axis range (min / max) according to provided data
mAxisLeft.calculate(mData.getYMin(YAxis.AxisDependency.LEFT), mData.getYMax(YAxis.AxisDependency.LEFT));
mAxisRight.calculate(mData.getYMin(YAxis.AxisDependency.RIGHT), mData.getYMax(YAxis.AxisDependency
.RIGHT));
}