Search in sources :

Example 6 with PlotDot

use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.

the class PlotLegendRender method renderRangeBarKey.

public void renderRangeBarKey(Canvas canvas, String key, int textColor) {
    if (isShow() == false)
        return;
    if ("" == key || key.length() == 0)
        return;
    refreshLst();
    mLstKey.add(key);
    mLstColor.add(textColor);
    PlotDot pDot = new PlotDot();
    pDot.setDotStyle(XEnum.DotStyle.RECT);
    mLstDotStyle.add(pDot);
    render(canvas);
}
Also used : PlotDot(org.xclcharts.renderer.line.PlotDot)

Example 7 with PlotDot

use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.

the class LineChart method renderLine.

/**
		 * 绘制线
		 * @param canvas	画布
		 * @param bd		数据类
		 * @param type		处理类型
		 */
private boolean renderLine(Canvas canvas, LineData bd, String type, int dataID) {
    if (null == categoryAxis || null == dataAxis)
        return false;
    if (null == bd) {
        Log.i(TAG, "传入的线的数据序列参数为空.");
        return false;
    }
    float initX = plotArea.getLeft();
    float initY = plotArea.getBottom();
    float lineStartX = initX, lineStartY = initY;
    float lineStopX = 0.0f, lineStopY = 0.0f;
    //得到分类轴数据集
    List<String> dataSet = categoryAxis.getDataSet();
    if (null == dataSet || dataSet.size() == 0) {
        Log.w(TAG, "分类轴数据为空.");
        return false;
    }
    //数据序列
    List<Double> chartValues = bd.getLinePoint();
    if (null == chartValues || chartValues.size() == 0) {
        Log.w(TAG, "当前分类的线数据序列值为空.");
        return false;
    }
    //步长	
    float XSteps = 0.0f;
    //,childID = 0;	
    int j = 0;
    int tickCount = dataSet.size();
    //label仅一个时右移 !mXCoordFirstTickmarksBegin && 
    if (1 == tickCount)
        j = 1;
    int labeltickCount = getCategoryAxisCount();
    XSteps = getVerticalXSteps(labeltickCount);
    float itemAngle = bd.getItemLabelRotateAngle();
    PlotLine pLine = bd.getPlotLine();
    PlotDot pDot = pLine.getPlotDot();
    float radius = pDot.getDotRadius();
    double bv = 0.d;
    //画线
    int count = chartValues.size();
    for (int i = 0; i < count; i++) {
        bv = chartValues.get(i);
        lineStopY = getVPValPosition(bv);
        if (mXCoordFirstTickmarksBegin) {
            lineStopX = add(initX, mul((j + 1), XSteps));
        } else {
            lineStopX = add(initX, mul(j, XSteps));
        }
        //当柱图与线图混合,且柱图柱形为BarCenterStyle.SPACE时
        if (mXCoordFirstTickmarksBegin && XEnum.BarCenterStyle.SPACE == mBarCenterStyle)
            lineStopX = sub(lineStopX, div(XSteps, 2));
        if (0 == j) {
            lineStartX = lineStopX;
            lineStartY = lineStopY;
        }
        if (getLineAxisIntersectVisible() == false && Double.compare(bv, dataAxis.getAxisMin()) == 0) {
            //如果值与最小值相等,即到了轴上,则忽略掉  
            lineStartX = lineStopX;
            lineStartY = lineStopY;
            j++;
        } else {
            if (type.equalsIgnoreCase("LINE")) {
                if (getLineAxisIntersectVisible() == true || Float.compare(lineStartY, initY) != 0) {
                    DrawHelper.getInstance().drawLine(bd.getLineStyle(), lineStartX, lineStartY, lineStopX, lineStopY, canvas, pLine.getLinePaint());
                }
            } else if (type.equalsIgnoreCase("DOT2LABEL")) {
                if (!pLine.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
                    PlotDotRender.getInstance().renderDot(canvas, pDot, lineStopX, lineStopY, //标识图形            		
                    pLine.getDotPaint());
                    savePointRecord(dataID, i, lineStopX + mMoveX, lineStopY + mMoveY, lineStopX - radius + mMoveX, lineStopY - radius + mMoveY, lineStopX + radius + mMoveX, lineStopY + radius + mMoveY);
                    lineStopX = add(lineStopX, radius);
                }
                //显示批注形状
                drawAnchor(getAnchorDataPoint(), dataID, i, canvas, lineStopX - radius, lineStopY, radius);
                if (//标签
                bd.getLabelVisible()) {
                    bd.getLabelOptions().drawLabel(canvas, pLine.getDotLabelPaint(), getFormatterItemLabel(bv), lineStopX - radius, lineStopY, itemAngle, bd.getLineColor());
                }
            } else {
                //我不认识你,我不认识你。
                Log.w(TAG, "未知的参数标识。");
                return false;
            }
            lineStartX = lineStopX;
            lineStartY = lineStopY;
            j++;
        }
    //if(bv != dataAxis.getAxisMin())
    }
    return true;
}
Also used : PlotDot(org.xclcharts.renderer.line.PlotDot) PlotLine(org.xclcharts.renderer.line.PlotLine)

Example 8 with PlotDot

use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.

the class RadarChart method renderDotAndLabel.

private void renderDotAndLabel(Canvas canvas, RadarData lineData, float currentX, float currentY, int dataID, int childID) {
    PlotLine plotLine = lineData.getPlotLine();
    float itemAngle = lineData.getItemLabelRotateAngle();
    if (!plotLine.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
        PlotDot pDot = plotLine.getPlotDot();
        float radius = pDot.getDotRadius();
        PlotDotRender.getInstance().renderDot(canvas, pDot, currentX, currentY, lineData.getPlotLine().getDotPaint());
        savePointRecord(dataID, childID, currentX, currentY, currentX - radius, currentY - radius, currentX + radius, currentY + radius);
    }
    //是否显示标签
    if (lineData.getLabelVisible()) {
        DrawHelper.getInstance().drawRotateText(this.getFormatterDotLabel(lineData.getLinePoint().get(childID)), currentX, currentY, itemAngle, canvas, lineData.getPlotLine().getDotLabelPaint());
    }
}
Also used : PlotDot(org.xclcharts.renderer.line.PlotDot) PlotLine(org.xclcharts.renderer.line.PlotLine)

Example 9 with PlotDot

use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.

the class ScatterData method getPlotDot.

/*
	 * 点的绘制类	
	 */
public PlotDot getPlotDot() {
    if (null == mPlotDot) {
        mPlotDot = new PlotDot();
        mPlotDot.setDotStyle(XEnum.DotStyle.DOT);
    }
    return mPlotDot;
}
Also used : PlotDot(org.xclcharts.renderer.line.PlotDot)

Example 10 with PlotDot

use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.

the class SplineChart method renderDotAndLabel.

private boolean renderDotAndLabel(Canvas canvas, SplineData spData, int dataID, List<PointF> lstPoints) {
    PlotLine pLine = spData.getPlotLine();
    if (pLine.getDotStyle().equals(XEnum.DotStyle.HIDE) == true && spData.getLabelVisible() == false) {
        return true;
    }
    float itemAngle = spData.getItemLabelRotateAngle();
    PlotDot pDot = pLine.getPlotDot();
    float radius = pDot.getDotRadius();
    int count = mLstDotInfo.size();
    for (int i = 0; i < count; i++) {
        DotInfo dotInfo = mLstDotInfo.get(i);
        if (!pLine.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
            PlotDotRender.getInstance().renderDot(canvas, pDot, dotInfo.mX, dotInfo.mY, //标识图形            			                	
            pLine.getDotPaint());
            savePointRecord(dataID, i, dotInfo.mX + mMoveX, dotInfo.mY + mMoveY, dotInfo.mX - radius + mMoveX, dotInfo.mY - radius + mMoveY, dotInfo.mX + radius + mMoveX, dotInfo.mY + radius + mMoveY);
        //childID++;
        }
        //Log.e("spchart","dataID:"+Float.toString(dataID));
        //Log.e("spchart","  I:"+Integer.toString(i));
        //显示批注形状
        drawAnchor(getAnchorDataPoint(), dataID, i, canvas, dotInfo.mX, dotInfo.mY, radius);
        if (spData.getLabelVisible()) {
            //请自行在回调函数中处理显示格式
            spData.getLabelOptions().drawLabel(canvas, pLine.getDotLabelPaint(), getFormatterDotLabel(dotInfo.getLabel()), dotInfo.mX, dotInfo.mY, itemAngle, spData.getLineColor());
        }
    }
    return true;
}
Also used : DotInfo(org.xclcharts.renderer.line.DotInfo) PlotDot(org.xclcharts.renderer.line.PlotDot) PlotLine(org.xclcharts.renderer.line.PlotLine)

Aggregations

PlotDot (org.xclcharts.renderer.line.PlotDot)17 Paint (android.graphics.Paint)7 PlotLine (org.xclcharts.renderer.line.PlotLine)4 DotInfo (org.xclcharts.renderer.line.DotInfo)2 Iterator (java.util.Iterator)1 Entry (java.util.Map.Entry)1 ArcLineData (org.xclcharts.chart.ArcLineData)1 BarData (org.xclcharts.chart.BarData)1 BubbleData (org.xclcharts.chart.BubbleData)1 PieData (org.xclcharts.chart.PieData)1 Legend (org.xclcharts.renderer.info.Legend)1