Java源码示例:com.github.mikephil.charting.charts.BarLineChartBase
示例1
@Override
public void run() {
Matrix save = mRunMatrixBuffer;
mViewPortHandler.zoom(scaleX, scaleY, save);
mViewPortHandler.refresh(save, view, false);
float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY();
float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX();
pts[0] = xValue - xValsInView / 2f;
pts[1] = yValue + yValsInView / 2f;
mTrans.pointValuesToPixel(pts);
mViewPortHandler.translate(pts, save);
mViewPortHandler.refresh(save, view, false);
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
recycleInstance(this);
}
示例2
@Override
public void run() {
Matrix save = mRunMatrixBuffer;
mViewPortHandler.zoom(scaleX, scaleY, save);
mViewPortHandler.refresh(save, view, false);
float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY();
float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX();
pts[0] = xValue - xValsInView / 2f;
pts[1] = yValue + yValsInView / 2f;
mTrans.pointValuesToPixel(pts);
mViewPortHandler.translate(pts, save);
mViewPortHandler.refresh(save, view, false);
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
recycleInstance(this);
}
示例3
@Override
public void run() {
Matrix save = mRunMatrixBuffer;
mViewPortHandler.zoom(scaleX, scaleY, save);
mViewPortHandler.refresh(save, view, false);
float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY();
float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX();
pts[0] = xValue - xValsInView / 2f;
pts[1] = yValue + yValsInView / 2f;
mTrans.pointValuesToPixel(pts);
mViewPortHandler.translate(pts, save);
mViewPortHandler.refresh(save, view, false);
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
recycleInstance(this);
}
示例4
public ChartInfoViewHandler(BarLineChartBase chart) {
mChart = chart;
mDetector = new GestureDetector(mChart.getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public void onLongPress(MotionEvent e) {
super.onLongPress(e);
mIsLongPress = true;
Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());
if (h != null) {
mChart.highlightValue(h, true);
mChart.disableScroll();
}
}
});
}
示例5
@Override
public void run() {
Matrix save = mViewPortHandler.zoom(scaleX, scaleY);
mViewPortHandler.refresh(save, view, false);
float valsInView = ((BarLineChartBase) view).getDeltaY(axisDependency) / mViewPortHandler.getScaleY();
float xsInView = ((BarLineChartBase) view).getXAxis().getValues().size() / mViewPortHandler.getScaleX();
pts[0] = xValue - xsInView / 2f;
pts[1] = yValue + valsInView / 2f;
mTrans.pointValuesToPixel(pts);
save = mViewPortHandler.translate(pts);
mViewPortHandler.refresh(save, view, false);
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
}
示例6
@Override
public void run() {
Matrix save = mViewPortHandler.zoom(scaleX, scaleY);
mViewPortHandler.refresh(save, view, false);
float valsInView = ((BarLineChartBase) view).getDeltaY(axisDependency) / mViewPortHandler.getScaleY();
float xsInView = ((BarLineChartBase) view).getXAxis().getValues().size() / mViewPortHandler.getScaleX();
pts[0] = xValue - xsInView / 2f;
pts[1] = yValue + valsInView / 2f;
mTrans.pointValuesToPixel(pts);
save = mViewPortHandler.translate(pts);
mViewPortHandler.refresh(save, view, false);
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
}
示例7
@ReactProp(name = "zoom")
public void setZoom(BarLineChartBase chart, ReadableMap propMap) {
if (BridgeUtils.validate(propMap, ReadableType.Number, "scaleX") &&
BridgeUtils.validate(propMap, ReadableType.Number, "scaleY") &&
BridgeUtils.validate(propMap, ReadableType.Number, "xValue") &&
BridgeUtils.validate(propMap, ReadableType.Number, "yValue")) {
YAxis.AxisDependency axisDependency = YAxis.AxisDependency.LEFT;
if (propMap.hasKey("axisDependency") &&
propMap.getString("axisDependency").equalsIgnoreCase("RIGHT")) {
axisDependency = YAxis.AxisDependency.RIGHT;
}
chart.zoom(
(float) propMap.getDouble("scaleX"),
(float) propMap.getDouble("scaleY"),
(float) propMap.getDouble("xValue"),
(float) propMap.getDouble("yValue"),
axisDependency
);
}
}
示例8
/**
* Constructor with initialization parameters.
*
* @param chart instance of the chart
* @param touchMatrix the touch-matrix of the chart
* @param dragTriggerDistance the minimum movement distance that will be interpreted as a "drag" gesture in dp (3dp equals
* to about 9 pixels on a 5.5" FHD screen)
*/
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends
IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix, float dragTriggerDistance) {
super(chart);
this.mMatrix = touchMatrix;
this.mDragTriggerDist = Utils.convertDpToPixel(dragTriggerDistance);
this.mMinScalePointerDistance = Utils.convertDpToPixel(3.5f);
}
示例9
/**
* Constructor with initialization parameters.
*
* @param chart instance of the chart
* @param touchMatrix the touch-matrix of the chart
* @param dragTriggerDistance the minimum movement distance that will be interpreted as a "drag" gesture in dp (3dp equals
* to about 9 pixels on a 5.5" FHD screen)
*/
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends
IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix, float dragTriggerDistance) {
super(chart);
this.mMatrix = touchMatrix;
this.mDragTriggerDist = Utils.convertDpToPixel(dragTriggerDistance);
this.mMinScalePointerDistance = Utils.convertDpToPixel(3.5f);
}
示例10
/**
* Constructor with initialization parameters.
*
* @param chart instance of the chart
* @param touchMatrix the touch-matrix of the chart
* @param dragTriggerDistance the minimum movement distance that will be interpreted as a "drag" gesture in dp (3dp equals
* to about 9 pixels on a 5.5" FHD screen)
*/
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends
IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix, float dragTriggerDistance) {
super(chart);
this.mMatrix = touchMatrix;
this.mDragTriggerDist = Utils.convertDpToPixel(dragTriggerDistance);
this.mMinScalePointerDistance = Utils.convertDpToPixel(3.5f);
}
示例11
@Override
public void onAxisChange(BarLineChartBase chart) {
float lowestVisibleX = chart.getLowestVisibleX();
if (lowestVisibleX <= chart.getXAxis().getAxisMinimum()) return;
int maxX = (int) chart.getHighestVisibleX();
int x = Math.min(maxX, mData.size() - 1);
HisData hisData = mData.get(x < 0 ? 0 : x);
setDescription(mChartVolume, "成交量 " + hisData.getVol());
}
示例12
@Override
public void onAxisChange(BarLineChartBase chart) {
float lowestVisibleX = chart.getLowestVisibleX();
if (lowestVisibleX <= chart.getXAxis().getAxisMinimum()) return;
int maxX = (int) chart.getHighestVisibleX();
int x = Math.min(maxX, mData.size() - 1);
HisData hisData = mData.get(x < 0 ? 0 : x);
setDescription(mChartPrice, String.format(Locale.getDefault(), "MA5:%.2f MA10:%.2f MA20:%.2f MA30:%.2f",
hisData.getMa5(), hisData.getMa10(), hisData.getMa20(), hisData.getMa30()));
setDescription(mChartVolume, "成交量 " + hisData.getVol());
setDescription(mChartMacd, String.format(Locale.getDefault(), "MACD:%.2f DEA:%.2f DIF:%.2f",
hisData.getMacd(), hisData.getDea(), hisData.getDif()));
setDescription(mChartKdj, String.format(Locale.getDefault(), "K:%.2f D:%.2f J:%.2f",
hisData.getK(), hisData.getD(), hisData.getJ()));
}
示例13
private void setupYAxes(BarLineChartBase chart) {
YAxis y = chart.getAxisLeft();
y.setDrawZeroLine(true);
y.setDrawLabels(false);
y.setDrawGridLines(false);
y.setDrawAxisLine(false);
y.setAxisMinimum(0);
y = chart.getAxisRight();
y.setDrawZeroLine(true);
y.setDrawLabels(false);
y.setDrawGridLines(false);
y.setDrawAxisLine(false);
y.setAxisMinimum(0);
}
示例14
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);
}
示例15
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
// 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);
}
}
示例16
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix) {
super(chart);
this.mMatrix = touchMatrix;
// this equals to about 9 pixels on a 5.5" FHD screen
this.mDragTriggerDist = Utils.convertDpToPixel(3f);
this.mMinScalePointerDistance = Utils.convertDpToPixel(3.5f);
}
示例17
@Override
public void setYAxis(Chart chart, ReadableMap propMap) {
BarLineChartBase barLineChart = (BarLineChartBase) chart;
if (BridgeUtils.validate(propMap, ReadableType.Map, "left")) {
YAxis leftYAxis = barLineChart.getAxisLeft();
setCommonAxisConfig(chart, leftYAxis, propMap.getMap("left"));
setYAxisConfig(leftYAxis, propMap.getMap("left"));
}
if (BridgeUtils.validate(propMap, ReadableType.Map, "right")) {
YAxis rightYAxis = barLineChart.getAxisRight();
setCommonAxisConfig(chart, rightYAxis, propMap.getMap("right"));
setYAxisConfig(rightYAxis, propMap.getMap("right"));
}
}
示例18
public XAxisRendererCurrentDay(ViewPortHandler viewPortHandler, MyXAxis xAxis, Transformer trans, BarLineChartBase chart) {
super(viewPortHandler, xAxis, trans);
mXAxis = xAxis;
mChart = chart;
}
示例19
public XAxisRendererKline(ViewPortHandler viewPortHandler, MyXAxis xAxis, Transformer trans, BarLineChartBase chart) {
super(viewPortHandler, xAxis, trans);
mXAxis = xAxis;
mChart = chart;
}
示例20
public CoupleChartGestureListener(BarLineChartBase srcChart, Chart... dstCharts) {
this.srcChart = srcChart;
this.dstCharts = dstCharts;
}
示例21
public DayAxisValueFormatter(BarLineChartBase<?> chart, List<Integer> xAxisEntryList) {
this.chart = chart;
this.xAxisEntryList = xAxisEntryList;
}
示例22
public TimeXAxisRenderer(ViewPortHandler viewPortHandler, TimeXAxis xAxis, Transformer trans, BarLineChartBase chart) {
super(viewPortHandler, xAxis, trans);
mXAxis = xAxis;
mChart = chart;
}
示例23
@Override
public void onAnimationEnd(Animator animation) {
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
}
示例24
public DayAxisValueFormatter(BarLineChartBase<?> chart) {
this.chart = chart;
}
示例25
@Override
public void onAnimationEnd(Animator animation) {
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
}
示例26
@Override
public void onAnimationEnd(Animator animation) {
((BarLineChartBase) view).calculateOffsets();
view.postInvalidate();
}
示例27
public CoupleChartGestureListener(OnAxisChangeListener listener, BarLineChartBase srcChart, Chart... dstCharts) {
this(srcChart, dstCharts);
this.listener = listener;
}
示例28
public CoupleChartGestureListener(BarLineChartBase srcChart, Chart... dstCharts) {
this.srcChart = srcChart;
this.dstCharts = dstCharts;
}
示例29
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends BarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix) {
super(chart);
this.mMatrix = touchMatrix;
}
示例30
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix) {
super(chart);
this.mMatrix = touchMatrix;
}