Search in sources :

Example 11 with PointPosition

use of org.xclcharts.event.click.PointPosition in project XCL-Charts by xcltapestry.

the class QuadrantChart01View 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 {
        PointPosition record = chart.getPositionRecord(x, y);
        if (null == record)
            return;
        BubbleData lData = chartData.get(record.getDataID());
        List<PointD> mapPoint = lData.getDataSet();
        int pos = record.getDataChildID();
        int i = 0;
        Iterator it = mapPoint.iterator();
        while (it.hasNext()) {
            PointD entry = (PointD) it.next();
            if (pos == i) {
                Double xValue = entry.x;
                Double yValue = entry.y;
                float r = record.getRadius();
                chart.showFocusPointF(record.getPosition(), r + r * 0.5f);
                chart.getFocusPaint().setStyle(Style.STROKE);
                chart.getFocusPaint().setStrokeWidth(3);
                if (record.getDataID() >= 3) {
                    chart.getFocusPaint().setColor(Color.WHITE);
                } else {
                    chart.getFocusPaint().setColor(Color.RED);
                }
                this.invalidate();
                break;
            }
            i++;
        }
    // end while
    }
// end if
}
Also used : BubbleData(org.xclcharts.chart.BubbleData) PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) PointPosition(org.xclcharts.event.click.PointPosition)

Example 12 with PointPosition

use of org.xclcharts.event.click.PointPosition in project XCL-Charts by xcltapestry.

the class BubbleChart01View 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 {
        PointPosition record = chart.getPositionRecord(x, y);
        if (null == record)
            return;
        BubbleData lData = chartData.get(record.getDataID());
        List<PointD> mapPoint = lData.getDataSet();
        int pos = record.getDataChildID();
        int i = 0;
        Iterator it = mapPoint.iterator();
        while (it.hasNext()) {
            PointD entry = (PointD) it.next();
            if (pos == i) {
                Double xValue = entry.x;
                Double yValue = entry.y;
                float r = record.getRadius();
                chart.showFocusPointF(record.getPosition(), r + r * 0.5f);
                chart.getFocusPaint().setStyle(Style.STROKE);
                chart.getFocusPaint().setStrokeWidth(3);
                if (record.getDataID() >= 3) {
                    chart.getFocusPaint().setColor(Color.WHITE);
                } else {
                    chart.getFocusPaint().setColor(Color.RED);
                }
                // 在点击处显示tooltip
                mPaintTooltips.setColor(Color.WHITE);
                chart.getToolTip().setCurrentXY(record.getPosition().x, record.getPosition().y);
                chart.getToolTip().addToolTip(" Key:" + lData.getKey(), mPaintTooltips);
                chart.getToolTip().addToolTip(Double.toString(xValue) + "," + Double.toString(yValue), mPaintTooltips);
                chart.getToolTip().setStyle(XEnum.DyInfoStyle.CAPRECT);
                chart.getToolTip().setAlign(Align.CENTER);
                chart.getToolTip().getBackgroundPaint().setColor(Color.parseColor("#9400D3"));
                this.invalidate();
                break;
            }
            i++;
        }
    // end while
    }
// end if
}
Also used : BubbleData(org.xclcharts.chart.BubbleData) PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) PointPosition(org.xclcharts.event.click.PointPosition) Paint(android.graphics.Paint)

Example 13 with PointPosition

use of org.xclcharts.event.click.PointPosition in project XCL-Charts by xcltapestry.

the class SplineChart01View 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 {
        PointPosition record = chart.getPositionRecord(x, y);
        if (null == record)
            return;
        if (record.getDataID() >= chartData.size())
            return;
        SplineData lData = chartData.get(record.getDataID());
        List<PointD> linePoint = lData.getLineDataSet();
        int pos = record.getDataChildID();
        int i = 0;
        Iterator it = linePoint.iterator();
        while (it.hasNext()) {
            PointD entry = (PointD) it.next();
            if (pos == i) {
                Double xValue = entry.x;
                Double yValue = entry.y;
                float r = record.getRadius();
                chart.showFocusPointF(record.getPosition(), r * 2);
                chart.getFocusPaint().setStyle(Style.STROKE);
                chart.getFocusPaint().setStrokeWidth(3);
                if (record.getDataID() >= 2) {
                    chart.getFocusPaint().setColor(Color.BLUE);
                } else {
                    chart.getFocusPaint().setColor(Color.RED);
                }
                // 在点击处显示tooltip
                pToolTip.setColor(Color.RED);
                chart.getToolTip().setCurrentXY(x, y);
                chart.getToolTip().addToolTip(" Key:" + lData.getLineKey(), pToolTip);
                chart.getToolTip().addToolTip(" Label:" + lData.getLabel(), pToolTip);
                chart.getToolTip().addToolTip(" Current Value:" + Double.toString(xValue) + "," + Double.toString(yValue), pToolTip);
                chart.getToolTip().getBackgroundPaint().setAlpha(100);
                this.invalidate();
                break;
            }
            i++;
        }
    // end while
    }
}
Also used : PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) SplineData(org.xclcharts.chart.SplineData) PointPosition(org.xclcharts.event.click.PointPosition) Paint(android.graphics.Paint) AnchorDataPoint(org.xclcharts.renderer.info.AnchorDataPoint)

Aggregations

PointPosition (org.xclcharts.event.click.PointPosition)13 Iterator (java.util.Iterator)7 PointD (org.xclcharts.chart.PointD)7 Paint (android.graphics.Paint)6 SplineData (org.xclcharts.chart.SplineData)4 AreaData (org.xclcharts.chart.AreaData)3 BubbleData (org.xclcharts.chart.BubbleData)2 RadarData (org.xclcharts.chart.RadarData)2 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)2 LineData (org.xclcharts.chart.LineData)1 ScatterData (org.xclcharts.chart.ScatterData)1