/** * initialize degrees on Y axis * * <p>Y軸の目盛を初期化 * * <p>初始化Y轴的坐标值 */ protected void initAxisX() { List<String> titleX = new ArrayList<String>(); if (null != stickData && stickData.size() > 0) { float average = displayNumber / this.getLongitudeNum(); for (int i = 0; i < this.getLongitudeNum(); i++) { int index = (int) Math.floor(i * average); if (index > displayNumber - 1) { index = displayNumber - 1; } index = index + displayFrom; titleX.add(formatAxisXDegree(stickData.get(index).getDate())); } titleX.add(formatAxisXDegree(stickData.get(displayFrom + displayNumber - 1).getDate())); } super.setLongitudeTitles(titleX); }
/* * (non-Javadoc) * * @param value * * @return * * @see * cn.limc.androidcharts.view.GridChart#getAxisXGraduate(java.lang.Object) */ @Override public String getAxisXGraduate(Object value) { float graduate = Float.valueOf(super.getAxisXGraduate(value)); int index = (int) Math.floor(graduate * displayNumber); if (index >= displayNumber) { index = displayNumber - 1; } else if (index < 0) { index = 0; } index = index + displayFrom; return formatAxisXDegree(stickData.get(index).getDate()); }
protected void drawSticks(Canvas canvas) { if (null == stickData) { return; } if (stickData.size() == 0) { return; } Paint mPaintStick = new Paint(); mPaintStick.setColor(stickFillColor); float stickWidth = getDataQuadrantPaddingWidth() / displayNumber - stickSpacing; float stickX = getDataQuadrantPaddingStartX(); for (int i = displayFrom; i < displayFrom + displayNumber; i++) { IMeasurable stick = stickData.get(i); float highY = (float) ((1f - (stick.getHigh() - minValue) / (maxValue - minValue)) * (getDataQuadrantPaddingHeight()) + getDataQuadrantPaddingStartY()); float lowY = (float) ((1f - (stick.getLow() - minValue) / (maxValue - minValue)) * (getDataQuadrantPaddingHeight()) + getDataQuadrantPaddingStartY()); // stick or line? if (stickWidth >= 2f) { canvas.drawRect(stickX, highY, stickX + stickWidth, lowY, mPaintStick); } else { canvas.drawLine(stickX, highY, stickX, lowY, mPaintStick); } // next x stickX = stickX + stickSpacing + stickWidth; } }