use of org.xclcharts.renderer.line.PlotLine 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());
}
}
use of org.xclcharts.renderer.line.PlotLine 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;
}
use of org.xclcharts.renderer.line.PlotLine in project XCL-Charts by xcltapestry.
the class AreaChart method renderDotAndLabel.
/**
* 绘制区域
*
* @param bd
* 数据序列
* @param type
* 绘制类型
* @param alpha
* 透明度
*/
private boolean renderDotAndLabel(Canvas canvas, AreaData bd, int dataID, List<DotInfo> lstDotInfo) {
float itemAngle = bd.getItemLabelRotateAngle();
PlotLine pLine = bd.getPlotLine();
if (pLine.getDotStyle().equals(XEnum.DotStyle.HIDE) == true && bd.getLabelVisible() == false) {
return true;
}
PlotDot pDot = pLine.getPlotDot();
float radius = pDot.getDotRadius();
int count = lstDotInfo.size();
for (int i = 0; i < count; i++) {
DotInfo dotInfo = lstDotInfo.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);
}
// 显示批注形状
drawAnchor(getAnchorDataPoint(), dataID, i, canvas, dotInfo.mX, dotInfo.mY, radius);
if (bd.getLabelVisible()) {
bd.getLabelOptions().drawLabel(canvas, pLine.getDotLabelPaint(), getFormatterItemLabel(dotInfo.mValue), dotInfo.mX, dotInfo.mY, itemAngle, bd.getLineColor());
}
}
return true;
}
use of org.xclcharts.renderer.line.PlotLine 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;
}