Search in sources :

Example 6 with PointPosition

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

the class AreaChart01View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    PointPosition record = chart.getPositionRecord(x, y);
    if (null == record)
        return;
    AreaData lData = mDataset.get(record.getDataID());
    Double lValue = lData.getLinePoint().get(record.getDataChildID());
    /*
		Toast.makeText(this.getContext(), 
				record.getPointInfo() +
				" Key:"+lData.getLineKey() +
				" Label:"+lData.getLabel() +								
				" Current Value:"+Double.toString(lValue), 
				Toast.LENGTH_SHORT).show();	
		*/
    float r = record.getRadius();
    chart.showFocusPointF(record.getPosition(), r + r * 0.5f);
    // chart.getFocusPaint().setStyle(Style.STROKE);
    chart.getFocusPaint().setStrokeWidth(3);
    chart.getFocusPaint().setColor(Color.RED);
    chart.getFocusPaint().setTextAlign(Align.CENTER);
    // 在点击处显示tooltip
    mPaintTooltips.setColor(Color.YELLOW);
    chart.getToolTip().getBackgroundPaint().setColor(Color.GRAY);
    // chart.getToolTip().setCurrentXY(x,y);
    chart.getToolTip().setCurrentXY(record.getPosition().x, record.getPosition().y);
    chart.getToolTip().setStyle(XEnum.DyInfoStyle.CAPRECT);
    chart.getToolTip().addToolTip(" Key:" + lData.getLineKey(), mPaintTooltips);
    chart.getToolTip().addToolTip(" Label:" + lData.getLabel(), mPaintTooltips);
    chart.getToolTip().addToolTip(" Current Value:" + Double.toString(lValue), mPaintTooltips);
    chart.getToolTip().setAlign(Align.CENTER);
    this.invalidate();
}
Also used : AreaData(org.xclcharts.chart.AreaData) PointPosition(org.xclcharts.event.click.PointPosition)

Example 7 with PointPosition

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

the class AreaChart02View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    PointPosition record = chart.getPositionRecord(x, y);
    if (null == record)
        return;
    AreaData lData = mDataset.get(record.getDataID());
    Double lValue = lData.getLinePoint().get(record.getDataChildID());
    Toast.makeText(this.getContext(), record.getPointInfo() + " Key:" + lData.getLineKey() + " Label:" + lData.getLabel() + " Current Value:" + Double.toString(lValue), Toast.LENGTH_SHORT).show();
}
Also used : AreaData(org.xclcharts.chart.AreaData) PointPosition(org.xclcharts.event.click.PointPosition)

Example 8 with PointPosition

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

the class RadarChart02View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    PointPosition record = chart.getPositionRecord(x, y);
    if (null == record)
        return;
    if (record.getDataID() < chartData.size()) {
        RadarData lData = chartData.get(record.getDataID());
        Double lValue = lData.getLinePoint().get(record.getDataChildID());
        Toast.makeText(this.getContext(), " Current Value:" + Double.toString(lValue) + " Point info:" + record.getPointInfo(), Toast.LENGTH_SHORT).show();
    }
}
Also used : RadarData(org.xclcharts.chart.RadarData) PointPosition(org.xclcharts.event.click.PointPosition)

Example 9 with PointPosition

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

the class ScatterChart01View 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;
        ScatterData lData = chartData.get(record.getDataID());
        List<PointD> linePoint = lData.getDataSet();
        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;
                // 在点击处显示tooltip
                mPaintTooltips.setColor(Color.RED);
                chart.getToolTip().setCurrentXY(x, y);
                chart.getToolTip().addToolTip(" Key:" + lData.getKey(), mPaintTooltips);
                chart.getToolTip().addToolTip(" Current Value:" + Double.toString(xValue) + "," + Double.toString(yValue), mPaintTooltips);
                this.invalidate();
                break;
            }
            i++;
        }
    // end while
    }
// end if
}
Also used : PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) PointPosition(org.xclcharts.event.click.PointPosition) ScatterData(org.xclcharts.chart.ScatterData) Paint(android.graphics.Paint)

Example 10 with PointPosition

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

the class SplineChart02View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    if (!chart.getListenItemClickStatus())
        return;
    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;
            Toast.makeText(this.getContext(), record.getPointInfo() + " Key:" + lData.getLineKey() + " Current Value(key,value):" + Double.toString(xValue) + "," + Double.toString(yValue), Toast.LENGTH_SHORT).show();
            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)

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