本文整理匯總了Java中com.github.mikephil.charting.highlight.Highlight類的典型用法代碼示例。如果您正苦於以下問題:Java Highlight類的具體用法?Java Highlight怎麽用?Java Highlight使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Highlight類屬於com.github.mikephil.charting.highlight包,在下文中一共展示了Highlight類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHighlightByTouchPoint
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
/**
* Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
* point
* inside the BarChart.
*
* @param x
* @param y
* @return
*/
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
} else {
Highlight h = getHighlighter().getHighlight(x, y);
if (h == null || !isHighlightFullBarEnabled()) return h;
// For isHighlightFullBarEnabled, remove stackIndex
return new Highlight(h.getX(), h.getY(),
h.getXPx(), h.getYPx(),
h.getDataSetIndex(), -1, h.getAxis());
}
}
示例2: getHighlightByTouchPoint
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
/**
* Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
* point
* inside the CombinedChart.
*
* @param x
* @param y
* @return
*/
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
} else {
Highlight h = getHighlighter().getHighlight(x, y);
if (h == null || !isHighlightFullBarEnabled()) return h;
// For isHighlightFullBarEnabled, remove stackIndex
return new Highlight(h.getX(), h.getY(),
h.getXPx(), h.getYPx(),
h.getDataSetIndex(), -1, h.getAxis());
}
}
示例3: onSingleTapUp
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public boolean onSingleTapUp(MotionEvent e) {
mLastGesture = ChartGesture.SINGLE_TAP;
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartSingleTapped(e);
}
if (!mChart.isHighlightPerTapEnabled()) {
return false;
}
Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());
performHighlight(h, e);
return super.onSingleTapUp(e);
}
示例4: onSingleTapUp
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public boolean onSingleTapUp(MotionEvent e) {
mLastGesture = ChartGesture.SINGLE_TAP;
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartSingleTapped(e);
}
if(!mChart.isHighlightPerTapEnabled()) {
return false;
}
Highlight high = mChart.getHighlightByTouchPoint(e.getX(), e.getY());
performHighlight(high, e);
return true;
}
示例5: onValueSelected
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mOnValueSelectedRectF;
mChart.getBarBounds((BarEntry) e, bounds);
MPPointF position = mChart.getPosition(e, AxisDependency.LEFT);
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
Log.i("x-index",
"low: " + mChart.getLowestVisibleX() + ", high: "
+ mChart.getHighestVisibleX());
MPPointF.recycleInstance(position);
}
示例6: refreshContent
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public void refreshContent(Entry e, Highlight highlight) {
if (e instanceof BarEntry) {
BarEntry be = (BarEntry) e;
if(be.getYVals() != null) {
// draw the stack value
tvContent.setText("" + Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true));
} else {
tvContent.setText("" + Utils.formatNumber(be.getY(), 0, true));
}
} else {
tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
}
super.refreshContent(e, highlight);
}
示例7: onValueSelected
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mOnValueSelectedRectF;
mChart.getBarBounds((BarEntry) e, bounds);
MPPointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(h.getDataSetIndex())
.getAxisDependency());
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
MPPointF.recycleInstance(position);
}
示例8: addDragListenerMarkerMaker
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
private void addDragListenerMarkerMaker(LineChart speedChart) {
speedChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry entry, Highlight h) {
Long entryX = (long) entry.getX();
if (timeLocationMap.containsKey(entryX)) {
clearAllMarkersFromMap();
LatLng latLng = timeLocationMap.get(entryX);
mapMarkers.add(googleMap.addMarker(new MarkerOptions().position(latLng)));
}
}
@Override
public void onNothingSelected() {
clearAllMarkersFromMap();
}
});
}
示例9: refreshContent
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public void refreshContent(Entry e, Highlight highlight) {
if (e instanceof CandleEntry) {
CandleEntry ce = (CandleEntry) e;
tvContent.setText(getContext().getString(R.string.salaries_format_salary,
(int) ce.getHigh()));
} else {
EntryMarkerData data = (EntryMarkerData) e.getData();
tvContent.setText(getContext().getString(R.string.exp_format_marker,
String.valueOf(data.getValue()),
String.valueOf(data.getCount())
)
);
}
super.refreshContent(e, highlight);
}
示例10: onBindViewHolder
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder ) {
final VerticalBarChartHolder barHolder = (VerticalBarChartHolder) holder;
barHolder.title.setText(title);
ChartHelper.setVerticalBarChart(context, barHolder.chart, getChartData(), typeface);
barHolder.chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null){
return;
}
barHolder.chart.setDrawMarkers(true);
}
@Override
public void onNothingSelected() {
}
});
}
示例11: onBindViewHolder
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder ) {
final LineChartHolder lineHolder = (LineChartHolder) holder;
lineHolder.language.setText(title);
ChartHelper.setLineChart(context, lineHolder.chart, getChartData(), month, typeface);
lineHolder.chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null){
return;
}
Timber.d("onValueSelected Selected:%s dataSet:%d", e.toString(), h.getDataSetIndex());
lineHolder.chart.setDrawMarkers(true);
}
@Override
public void onNothingSelected() {
Timber.d("Nothing selected.");
}
});
}
示例12: refreshContent
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public void refreshContent(Entry e, Highlight highlight) {
String content;
if (mWhatData == SHOW_FUEL_PRICE_EVOLUTION)
content = String.format(mCtx.getString(R.string.line_chart_fuel_price_marker_text),
Utils.numberToString(e.getY(), true, ConstantValues.DECIMALS_PRICE, ConstantValues.ROUNDING_MODE_PRICE),
Utils.getFormattedDateTime((mChartDates.get((int) e.getX())) * 1000, true));
else
content = Utils.numberToString(e.getY(), true, ConstantValues.DECIMALS_FUEL_EFF, ConstantValues.ROUNDING_MODE_FUEL_EFF);
tvContent.setText(content);
//resize the marker view.
//see https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartLib/src/main/java/com/github/mikephil/charting/components/MarkerView.java
measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
}
示例13: refreshContent
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@Override
public void refreshContent(Entry e, Highlight highlight) {
SharedPreferences sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(tvContent.getContext().getApplicationContext());
if (e instanceof CandleEntry) {
CandleEntry ce = (CandleEntry) e;
tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
} else {
if(sharedPrefs.getString("pref_unit", "mg/dl").equals("mg/dl")) {
tvContent.setText("" + Utils.formatNumber(e.getVal(), 0, true));
}else{
tvContent.setText("" + Utils.formatNumber(e.getVal(), 1, true));
}
}
}
示例14: onValueSelected
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mOnValueSelectedRectF;
mChart.getBarBounds((BarEntry) e, bounds);
MPPointF position = mChart.getPosition(e, YAxis.AxisDependency.LEFT);
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
Log.i("x-index",
"low: " + mChart.getLowestVisibleX() + ", high: "
+ mChart.getHighestVisibleX());
MPPointF.recycleInstance(position);
}
示例15: onValueSelected
import com.github.mikephil.charting.highlight.Highlight; //導入依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
if (e == null)
return;
RectF bounds = mChart.getBarBounds((BarEntry) e);
PointF position = mChart.getPosition(e, AxisDependency.LEFT);
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
Log.i("x-index",
"low: " + mChart.getLowestVisibleXIndex() + ", high: "
+ mChart.getHighestVisibleXIndex());
}