use of org.xclcharts.event.click.BarPosition in project XCL-Charts by xcltapestry.
the class RangeBarChart01View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
BarPosition record = chart.getPositionRecord(x, y);
if (null == record)
return;
/*
RangeBarData bData = BarDataSet.get(record.getDataID());
Toast.makeText(this.getContext(),
"info:" + record.getRectInfo() +
" Min:" + Double.toString( bData.getMin()) +
" Max:" + Double.toString( bData.getMax()) ,
Toast.LENGTH_SHORT).show();
*/
// 显示选中框
chart.showFocusRectF(record.getRectF());
chart.getFocusPaint().setStyle(Style.STROKE);
chart.getFocusPaint().setStrokeWidth(3);
chart.getFocusPaint().setColor(Color.RED);
this.invalidate();
}
use of org.xclcharts.event.click.BarPosition in project XCL-Charts by xcltapestry.
the class StackBarChart02View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
BarPosition record = chart.getPositionRecord(x, y);
if (null == record)
return;
if (record.getDataID() >= BarDataSet.size())
return;
BarData bData = BarDataSet.get(record.getDataID());
Double bValue = bData.getDataSet().get(record.getDataChildID());
chart.showFocusRectF(record.getRectF());
chart.getFocusPaint().setStyle(Style.FILL);
chart.getFocusPaint().setStrokeWidth(3);
chart.getFocusPaint().setColor(Color.GRAY);
chart.getFocusPaint().setAlpha(100);
// 在点击处显示tooltip
pToolTip.setColor(Color.WHITE);
chart.getToolTip().setAlign(Align.CENTER);
chart.getToolTip().getBackgroundPaint().setColor(Color.BLUE);
chart.getToolTip().setInfoStyle(XEnum.DyInfoStyle.CAPROUNDRECT);
// chart.getToolTip().setCurrentXY(x,y);
chart.getToolTip().setCurrentXY(record.getRectF().centerX(), record.getRectF().top);
chart.getToolTip().addToolTip(" Current Value:" + Double.toString(bValue), pToolTip);
this.invalidate();
}
use of org.xclcharts.event.click.BarPosition in project XCL-Charts by xcltapestry.
the class BarChart09View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
BarPosition record = chart.getPositionRecord(x, y);
if (null == record)
return;
BarData bData = chartData.get(record.getDataID());
Double bValue = bData.getDataSet().get(record.getDataChildID());
Toast.makeText(this.getContext(), "info:" + record.getRectInfo() + " Key:" + bData.getKey() + " Current Value:" + Double.toString(bValue), Toast.LENGTH_SHORT).show();
chart.showFocusRectF(record.getRectF());
chart.getFocusPaint().setStyle(Style.STROKE);
chart.getFocusPaint().setStrokeWidth(3);
chart.getFocusPaint().setColor(Color.GREEN);
this.invalidate();
}
use of org.xclcharts.event.click.BarPosition in project XCL-Charts by xcltapestry.
the class BarChart11View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
BarPosition record = chart.getPositionRecord(x, y);
if (null == record)
return;
BarData bData = chartData.get(record.getDataID());
Double bValue = bData.getDataSet().get(record.getDataChildID());
Toast.makeText(this.getContext(), "info:" + record.getRectInfo() + " Key:" + bData.getKey() + " Current Value:" + Double.toString(bValue), Toast.LENGTH_SHORT).show();
chart.showFocusRectF(record.getRectF());
chart.getFocusPaint().setStyle(Style.STROKE);
chart.getFocusPaint().setStrokeWidth(3);
chart.getFocusPaint().setColor(Color.GREEN);
this.invalidate();
}
use of org.xclcharts.event.click.BarPosition in project XCL-Charts by xcltapestry.
the class BarChart01View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
// 交叉线
if (chart.getDyLineVisible())
chart.getDyLine().setCurrentXY(x, y);
if (!chart.getListenItemClickStatus()) {
// 交叉线
if (chart.getDyLineVisible() && chart.getDyLine().isInvalidate())
this.invalidate();
} else {
BarPosition record = chart.getPositionRecord(x, y);
if (null == record) {
if (chart.getDyLineVisible())
this.invalidate();
return;
}
if (record.getDataID() >= chartData.size())
return;
BarData bData = chartData.get(record.getDataID());
if (record.getDataChildID() >= bData.getDataSet().size())
return;
Double bValue = bData.getDataSet().get(record.getDataChildID());
// 显示选中框
chart.showFocusRectF(record.getRectF());
chart.getFocusPaint().setStyle(Style.STROKE);
chart.getFocusPaint().setStrokeWidth(3);
chart.getFocusPaint().setColor(Color.GREEN);
// 在点击处显示tooltip
mPaintToolTip.setAntiAlias(true);
mPaintToolTip.setColor(bData.getColor());
mDotToolTip.setDotStyle(XEnum.DotStyle.RECT);
// bData.getColor());
mDotToolTip.setColor(Color.BLUE);
// 位置显示方法一:
// 用下列方法可以让tooltip显示在柱形顶部
// chart.getToolTip().setCurrentXY(record.getRectF().centerX(),record.getRectF().top);
// 位置显示方法二:
// 用下列方法可以让tooltip在所点击位置显示
chart.getToolTip().setCurrentXY(x, y);
chart.getToolTip().setStyle(XEnum.DyInfoStyle.ROUNDRECT);
chart.getToolTip().addToolTip(mDotToolTip, bData.getKey(), mPaintToolTip);
chart.getToolTip().addToolTip("数量:" + Double.toString(bValue), mPaintToolTip);
chart.getToolTip().getBackgroundPaint().setAlpha(100);
chart.getToolTip().setAlign(Align.CENTER);
chart.getToolTip().setInfoStyle(XEnum.DyInfoStyle.CIRCLE);
// chart.getToolTip().getBackgroundPaint().setColor(Color.rgb(30, 30, 30));
this.invalidate();
}
}
Aggregations