Skip to content

Commit

Permalink
添加 设置 Y 轴标签对齐方向属性
Browse files Browse the repository at this point in the history
  • Loading branch information
siterhow committed Apr 24, 2017
1 parent 55fc587 commit 2009c0f
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 81 deletions.
6 changes: 6 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.1.2

> 2017.04.24
添加 设置 Y 轴标签对齐方向属性

### 0.1.1

> 2017.04.17
Expand Down
151 changes: 76 additions & 75 deletions PROPERTY.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,103 @@
### 与轴、网格有关的属性和方法

| XML | Java Code | Comment |
| -------------------- | ------------------- | --------------- |
| app:xLabelSize | setXLabelSize | X 轴标签字符大小 |
| app:xLabelColor | setXLabelColor | X 轴标签字符颜色 |
| app:xLabelViewHeight | setXLabelViewHeight | X 轴 Label 区域的高度 |
| app:yLabelSize | setYLabelSize | Y 轴标签字符大小 |
| app:yLabelColor | setYLabelColor | Y 轴标签字符颜色 |
| app:axisSize | setAxisSize | 轴线条大小 |
| app:axisColor | setAxisColor | 轴线条颜色 |
| app:gridSize | setGridSize | 网格线大小 |
| app:gridColor | setGridColor | 网格线颜色 |
| XML | Java Code | Comment | Since |
| -------------------- | ------------------- | --------------------------- | ----- |
| app:xLabelSize | setXLabelSize | X 轴标签字符大小 | 0.1.0 |
| app:xLabelColor | setXLabelColor | X 轴标签字符颜色 | 0.1.0 |
| app:xLabelViewHeight | setXLabelViewHeight | X 轴 Label 区域的高度 | 0.1.0 |
| app:yLabelSize | setYLabelSize | Y 轴标签字符大小 | 0.1.0 |
| app:yLabelColor | setYLabelColor | Y 轴标签字符颜色 | 0.1.0 |
| app:yLabelAlign | setYLabelAlign | Y 轴标签对齐方向 1: left, 2: right | 0.1.2 |
| app:axisSize | setAxisSize | 轴线条大小 | 0.1.0 |
| app:axisColor | setAxisColor | 轴线条颜色 | 0.1.0 |
| app:gridSize | setGridSize | 网格线大小 | 0.1.0 |
| app:gridColor | setGridColor | 网格线颜色 | 0.1.0 |



### 与高亮、MarkerView 有关的属性和方法

| XML | Java Code | Comment |
| --------------------- | -------------------- | --------------- |
| app:highlightSize | setHighlightSize | 高亮线条大小 |
| app:highlightColor | setHighlightColor | 高亮线条颜色 |
| app:markerBorderSize | setMarkerBorderSize | MarkerView 边框大小 |
| app:markerBorderColor | setMarkerBorderColor | MarkerView 边框颜色 |
| app:markerTextSize | setMarkerTextSize | MarkerView 字符大小 |
| app:markerTextColor | setMarkerTextColor | MarkerView 字符颜色 |
| XML | Java Code | Comment | Since |
| --------------------- | -------------------- | --------------- | ----- |
| app:highlightSize | setHighlightSize | 高亮线条大小 | 0.1.0 |
| app:highlightColor | setHighlightColor | 高亮线条颜色 | 0.1.0 |
| app:markerBorderSize | setMarkerBorderSize | MarkerView 边框大小 | 0.1.0 |
| app:markerBorderColor | setMarkerBorderColor | MarkerView 边框颜色 | 0.1.0 |
| app:markerTextSize | setMarkerTextSize | MarkerView 字符大小 | 0.1.0 |
| app:markerTextColor | setMarkerTextColor | MarkerView 字符颜色 | 0.1.0 |



### 与分时图有关的属性和方法

| XML | Java Code | Comment |
| ----------------- | ---------------- | ------- |
| app:timeLineSize | setTimeLineSize | 分时线大小 |
| app:timeLineColor | setTimeLineColor | 分时线颜色 |
| XML | Java Code | Comment | Since |
| ----------------- | ---------------- | ------- | ----- |
| app:timeLineSize | setTimeLineSize | 分时线大小 | 0.1.0 |
| app:timeLineColor | setTimeLineColor | 分时线颜色 | 0.1.0 |



### 与蜡烛图有关的属性和方法

| XML | Java Code | Comment |
| ------------------------------- | ------------------------------ | ------------ |
| app:candleBorderSize | setCandleBorderSize | 蜡烛图矩形边框大小 |
| app:candleExtremumLabelSize | setCandleExtremumLabelSize | 蜡烛图极值字符大小 |
| app:candleExtremumLableColor | setCandleExtremumLableColor | 蜡烛图极值字符颜色 |
| app:shadowSize | setShadowSize | 影线大小 |
| app:increasingColor | setIncreasingColor | 上涨颜色 |
| app:decreasingColor | setDecreasingColor | 下跌颜色 |
| app:neutralColor | setNeutralColor | 不涨不跌颜色 |
| app:portraitDefaultVisibleCount | setPortraitDefaultVisibleCount | 竖屏默认显示多少个蜡烛图 |
| app:zoomInTimes | setZoomInTimes | 最多放大次数 |
| app:zoomOutTimes | setZoomOutTimes | 最多缩小次数 |
| XML | Java Code | Comment | Since |
| ------------------------------- | ------------------------------ | ------------ | ----- |
| app:candleBorderSize | setCandleBorderSize | 蜡烛图矩形边框大小 | 0.1.0 |
| app:candleExtremumLabelSize | setCandleExtremumLabelSize | 蜡烛图极值字符大小 | 0.1.0 |
| app:candleExtremumLableColor | setCandleExtremumLableColor | 蜡烛图极值字符颜色 | 0.1.0 |
| app:shadowSize | setShadowSize | 影线大小 | 0.1.0 |
| app:increasingColor | setIncreasingColor | 上涨颜色 | 0.1.0 |
| app:decreasingColor | setDecreasingColor | 下跌颜色 | 0.1.0 |
| app:neutralColor | setNeutralColor | 不涨不跌颜色 | 0.1.0 |
| app:portraitDefaultVisibleCount | setPortraitDefaultVisibleCount | 竖屏默认显示多少个蜡烛图 | 0.1.0 |
| app:zoomInTimes | setZoomInTimes | 最多放大次数 | 0.1.0 |
| app:zoomOutTimes | setZoomOutTimes | 最多缩小次数 | 0.1.0 |



### 与股票指标有关的属性和方法

| XML | Java Code | Comment |
| -------------------------- | ------------------------- | --------------- |
| app:maLineSize | setMaLineSize | MA 平均线大小 |
| app:ma5Color | setMa5Color | MA5 平均线颜色 |
| app:ma10Color | setMa10Color | MA10 平均线颜色 |
| app:ma20Color | setMa20Color | MA20 平均线颜色 |
| app:bollLineSize | setBollLineSize | BOLL 线条大小 |
| app:bollMidLineColor | setBollMidLineColor | BOLL MID 线条颜色 |
| app:bollUpperLineColor | setBollUpperLineColor | BOLL UPPER 线条颜色 |
| app:bollLowerLineColor | setBollLowerLineColor | BOLL LOWER 线条颜色 |
| app:kdjLineSize | setKdjLineSize | KDJ 线条大小 |
| app:kdjKLineColor | setKdjKLineColor | KDJ K 线条颜色 |
| app:kdjDLineColor | setKdjDLineColor | KDJ D 线条颜色 |
| app:kdjJLineColor | setKdjJLineColor | KDJ J 线条颜色 |
| app:macdLineSize | setMacdLineSize | MACD 两条线大小 |
| app:macdHighlightTextColor | setMacdHighlightTextColor | 高亮的 MACD 字符颜色 |
| app:deaLineColor | setDeaLineColor | DEA 线条颜色 |
| app:diffLineColor | setDiffLineColor | DIFF 线条颜色 |
| app:rsiLineSize | setRsiLineSize | RSI 线条大小 |
| app:rsi1LineColor | setRsi1LineColor | RSI 第一条线颜色 |
| app:rsi2LineColor | setRsi2LineColor | RSI 第二条线颜色 |
| app:rsi3LineColor | setRsi3LineColor | RSI 第三条线颜色 |
| app:maTextSize | setMaTextSize | MA 字符大小 |
| app:maTextColor | setMaTextColor | MA 字符颜色 |
| app:bollTextSize | setBollTextSize | BOLL 字符大小 |
| app:bollTextColor | setBollTextColor | BOLL 字符颜色 |
| app:kdjTextSize | setKdjTextSize | KDJ 字符大小 |
| app:kdjTextColor | setKdjTextColor | KDJ 字符颜色 |
| app:macdTextSize | setMacdTextSize | MACD 字符大小 |
| app:macdTextColor | setMacdTextColor | MACD 字符颜色 |
| app:rsiTextSize | setRsiTextSize | RSI 字符大小 |
| app:rsiTextColor | setRsiTextColor | RSI 字符颜色 |
| XML | Java Code | Comment | Since |
| -------------------------- | ------------------------- | --------------- | ----- |
| app:maLineSize | setMaLineSize | MA 平均线大小 | 0.1.0 |
| app:ma5Color | setMa5Color | MA5 平均线颜色 | 0.1.0 |
| app:ma10Color | setMa10Color | MA10 平均线颜色 | 0.1.0 |
| app:ma20Color | setMa20Color | MA20 平均线颜色 | 0.1.0 |
| app:bollLineSize | setBollLineSize | BOLL 线条大小 | 0.1.0 |
| app:bollMidLineColor | setBollMidLineColor | BOLL MID 线条颜色 | 0.1.0 |
| app:bollUpperLineColor | setBollUpperLineColor | BOLL UPPER 线条颜色 | 0.1.0 |
| app:bollLowerLineColor | setBollLowerLineColor | BOLL LOWER 线条颜色 | 0.1.0 |
| app:kdjLineSize | setKdjLineSize | KDJ 线条大小 | 0.1.0 |
| app:kdjKLineColor | setKdjKLineColor | KDJ K 线条颜色 | 0.1.0 |
| app:kdjDLineColor | setKdjDLineColor | KDJ D 线条颜色 | 0.1.0 |
| app:kdjJLineColor | setKdjJLineColor | KDJ J 线条颜色 | 0.1.0 |
| app:macdLineSize | setMacdLineSize | MACD 两条线大小 | 0.1.0 |
| app:macdHighlightTextColor | setMacdHighlightTextColor | 高亮的 MACD 字符颜色 | 0.1.0 |
| app:deaLineColor | setDeaLineColor | DEA 线条颜色 | 0.1.0 |
| app:diffLineColor | setDiffLineColor | DIFF 线条颜色 | 0.1.0 |
| app:rsiLineSize | setRsiLineSize | RSI 线条大小 | 0.1.0 |
| app:rsi1LineColor | setRsi1LineColor | RSI 第一条线颜色 | 0.1.0 |
| app:rsi2LineColor | setRsi2LineColor | RSI 第二条线颜色 | 0.1.0 |
| app:rsi3LineColor | setRsi3LineColor | RSI 第三条线颜色 | 0.1.0 |
| app:maTextSize | setMaTextSize | MA 字符大小 | 0.1.0 |
| app:maTextColor | setMaTextColor | MA 字符颜色 | 0.1.0 |
| app:bollTextSize | setBollTextSize | BOLL 字符大小 | 0.1.0 |
| app:bollTextColor | setBollTextColor | BOLL 字符颜色 | 0.1.0 |
| app:kdjTextSize | setKdjTextSize | KDJ 字符大小 | 0.1.0 |
| app:kdjTextColor | setKdjTextColor | KDJ 字符颜色 | 0.1.0 |
| app:macdTextSize | setMacdTextSize | MACD 字符大小 | 0.1.0 |
| app:macdTextColor | setMacdTextColor | MACD 字符颜色 | 0.1.0 |
| app:rsiTextSize | setRsiTextSize | RSI 字符大小 | 0.1.0 |
| app:rsiTextColor | setRsiTextColor | RSI 字符颜色 | 0.1.0 |



### 其它

| XML | Java Code | Comment |
| -------------------- | ------------------- | ------------ |
| app:loadingTextSize | setLoadingTextSize | loading 字符大小 |
| app:loadingTextColor | setLoadingTextColor | loading 字符颜色 |
| app:loadingText | setLoadingText | loading 字符 |
| app:errorTextSize | setErrorTextSize | error 字符大小 |
| app:errorTextColor | setErrorTextColor | error 字符颜色 |
| app:errorText | setErrorText | error 字符 |
| XML | Java Code | Comment | Since |
| -------------------- | ------------------- | ------------ | ----- |
| app:loadingTextSize | setLoadingTextSize | loading 字符大小 | 0.1.0 |
| app:loadingTextColor | setLoadingTextColor | loading 字符颜色 | 0.1.0 |
| app:loadingText | setLoadingText | loading 字符 | 0.1.0 |
| app:errorTextSize | setErrorTextSize | error 字符大小 | 0.1.0 |
| app:errorTextColor | setErrorTextColor | error 字符颜色 | 0.1.0 |
| app:errorText | setErrorText | error 字符 | 0.1.0 |
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Features

当前最新版本:0.1.1 (2017.04.17)
当前最新版本:0.1.2 (2017.04.24)

支持在 XML 布局文件和代码中设置各个线条颜色、大小配置

Expand All @@ -23,7 +23,7 @@
## Usage

```groovy
compile 'com.wordplat:ikvStockChart:0.1.1'
compile 'com.wordplat:ikvStockChart:0.1.2'
```

```xml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.wordplat.ikvstockchart.InteractiveKLineView
android:id="@+id/kLineView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:yLabelAlign="right"/>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public static SizeColor getSizeColor(Context context, AttributeSet attrs, int de
sizeColor.setYLabelColor(a.getColor(R.styleable.InteractiveKLineView_yLabelColor,
sizeColor.getYLabelColor()));

sizeColor.setYLabelAlign(a.getInteger(R.styleable.InteractiveKLineView_yLabelAlign, 1));

sizeColor.setAxisSize(a.getDimension(R.styleable.InteractiveKLineView_axisSize,
sizeColor.getAxisSize()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class KLineGridAxisDrawing implements IDrawing {
private final float[] pointCache = new float[2];
private float lineHeight;

private int yLabelAlign = 1; // Y 轴标签对齐方向 1: left, 2: right

@Override
public void onInit(RectF contentRect, AbstractRender render) {
this.render = (KLineRender) render;
Expand All @@ -69,6 +71,10 @@ public void onInit(RectF contentRect, AbstractRender render) {
}
yLabelPaint.setTextSize(sizeColor.getYLabelSize());
yLabelPaint.setColor(sizeColor.getYLabelColor());
yLabelAlign = sizeColor.getYLabelAlign();
if (yLabelAlign == 2) {
yLabelPaint.setTextAlign(Paint.Align.RIGHT);
}

if (axisPaint == null) {
axisPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Expand Down Expand Up @@ -158,7 +164,9 @@ public void onDrawOver(Canvas canvas) {
pointCache[0] = lineTop + fontMetrics.bottom;
}

canvas.drawText(value, kLineRect.left + 5, pointCache[0], yLabelPaint);
float labelX = yLabelAlign == 1 ? kLineRect.left + 5 : kLineRect.right - 5;

canvas.drawText(value, labelX, pointCache[0], yLabelPaint);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class StockIndexYLabelDrawing implements IDrawing {

private final RectF indexRect = new RectF();

private int yLabelAlign = 1; // Y 轴标签对齐方向 1: left, 2: right

@Override
public void onInit(RectF contentRect, AbstractRender render) {
final SizeColor sizeColor = render.getSizeColor();
Expand All @@ -52,6 +54,10 @@ public void onInit(RectF contentRect, AbstractRender render) {
}
yLabelPaint.setColor(sizeColor.getYLabelColor());
yLabelPaint.getFontMetrics(fontMetrics);
yLabelAlign = sizeColor.getYLabelAlign();
if (yLabelAlign == 2) {
yLabelPaint.setTextAlign(Paint.Align.RIGHT);
}

indexRect.set(contentRect);
}
Expand All @@ -63,15 +69,17 @@ public void computePoint(int minIndex, int maxIndex, int currentIndex) {

@Override
public void onComputeOver(Canvas canvas, int minIndex, int maxIndex, float minY, float maxY) {
float labelX = yLabelAlign == 1 ? indexRect.left + 5 : indexRect.right - 5;

canvas.drawText(
decimalFormatter.format(maxY),
indexRect.left + 5,
labelX,
indexRect.top - fontMetrics.top,
yLabelPaint);

canvas.drawText(
decimalFormatter.format(minY),
indexRect.left + 5,
labelX,
indexRect.bottom - fontMetrics.bottom,
yLabelPaint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class SizeColor {
private float xLabelViewHeight = 50; // X 轴 Label 区域的高度
private float yLabelSize = 21; // Y 轴标签字符大小
private int yLabelColor = 0xff282b34; // Y 轴标签字符颜色
private int yLabelAlign = 1; // Y 轴标签对齐方向 1: left, 2: right

private float axisSize = 2f; // 轴线条大小
private int axisColor = 0xffdddddd; // 轴线条颜色
Expand Down Expand Up @@ -82,6 +83,14 @@ public void setYLabelColor(int yLabelColor) {
this.yLabelColor = yLabelColor;
}

public int getYLabelAlign() {
return yLabelAlign;
}

public void setYLabelAlign(int yLabelAlign) {
this.yLabelAlign = yLabelAlign;
}

public float getAxisSize() {
return axisSize;
}
Expand Down
4 changes: 4 additions & 0 deletions ikvStockChart/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

<attr name="yLabelSize" format="dimension" />
<attr name="yLabelColor" format="color" />
<attr name="yLabelAlign">
<enum name="left" value="1" />
<enum name="right" value="2" />
</attr>

<attr name="axisSize" format="dimension" />
<attr name="axisColor" format="color" />
Expand Down

0 comments on commit 2009c0f

Please sign in to comment.