diff --git a/README.md b/README.md index ba98ad2b4231ce0508cb7a25bbd2da5aaf116c10..e2a9199f05c925fa0e884da0ac3e266891a2dfaf 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,35 @@ -# GraphView_openharmony +# GraphView_openharmony + ### 折线图/圆点图/柱状图 ![image](image/demo1.gif) -## 集成配置 +## 安装说明 -``` -方式一: -1.将graphView-library.har放到相应module的libs目录下 -2.如果已经有implementation fileTree(dir: 'libs', include: ['.jar']),则修改为implementation fileTree(dir: 'libs', include: ['.jar','.har']) - 如果没有,直接添加依赖 implementation fileTree(dir: 'libs', include: ['.jar','*.har']) 即可 -``` +Method 1:For using circularfillableloaders module in sample app ,add the +below dependency to generate hap/har,Modify entry/build.gradle as below: -``` -方式二: -allprojects{ - repositories{ - mavenCentral() + + dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + testCompile'junit:junit:4.12' + implementation project(':graphveiw') } -} -implementation 'io.openharmony.tpc.thirdlib:graphView-library:1.0.2' -``` +Method 2:For using circularfillableloaders in separate application using har file ,generate .har package through library and add the har file to the entry/libs folder.Modify entry/build.gradle as below: + + implementation fileTree(dir: 'libs', include: ['*.jar']) + +Method 3:For using circularfillableloaders in separate application using maven dependency,modify entry/build.gradle as below: + + dependencies { + implementation 'io.openharmony.tpc.thirdlib:graphView-library:1.0.2' + } -#### 一.GraphView介绍 + + +#### 一.GraphView 介绍 public void appendData(E dataPoint,boolean scrollToEnd,int maxDataPoints,boolean silent); @@ -15,7 +14,7 @@ v1.1.0 5. Viewport --> public boolean setScrollable(boolean mIsScrollable); 6. Viewport --> public boolean isScalable(); 7. Viewport --> public boolean setScalable(boolean mIsScalable); -8. Viewport --> public boolean scalableTOEnd(); +8. Viewport --> public void scrollToEnd(); 9. Viewport --> public OnXAxisBoundsChangedListener getOnXAxisBoundsChangedListener (); 10. Viewport --> public void setOnXAxisBoundListener(OnXAxisBoundsChangedListener l); 11. Viewport --> public void setScrollableY(boolean scrollableY); @@ -26,10 +25,12 @@ v1.1.0 16. Viewport --> public double setMaxYAxisSize(double mMaxYAxisViewportSize); 16. Viewport --> public double setMinimalViewport(double minX,double maxX,double minY,double maxY); 17. StaticLabelsFormatter -- >StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graphView_01,new String[] {"old", "new"},new String[] {"high", "low"}); + (当静态标签格式化程序传递2个不同的垂直标签时,它显示两次第一个标签,而不是显示两个集合标签。) 18. GraphView --> public class GraphView 内takeSnapshotAndShare() 19. LineGraphSeries--> public class LineGraphSeries 内 public void setDrawAsPath() 20. LineGraphSeries -->public class LineGraphSeries 内 public void setAnimated(boolean animated) 21. BarGraphSeries --> public class BarGraphSeries 内 public void setAnimated(boolean animated) 22. Viewport --> public class Viewport 内OverScroller / onScroll 23. LineGraphSeries --> public class LineGraphSeries 内 AccelerateInterpolator - \ No newline at end of file +24. 如果2个图形系列具有相同的系列标题,具有不同的系列颜色,则图例中仅显示第一个系列信息 +25. 如果Y轴使用最大值或字符串,如静态标签格式化程序的中心,标签将被削减 \ No newline at end of file diff --git a/graphveiw/src/main/java/com/jjoe64/graphview/CursorMode.java b/graphveiw/src/main/java/com/jjoe64/graphview/CursorMode.java index cb8c250cfc65c4418161867f10d66ddf9841ef8a..9836632fb40c32e7d5ef02c6ede61832b25901f8 100644 --- a/graphveiw/src/main/java/com/jjoe64/graphview/CursorMode.java +++ b/graphveiw/src/main/java/com/jjoe64/graphview/CursorMode.java @@ -94,10 +94,10 @@ public class CursorMode { } } - public void draw(Canvas canvas,int width,int height) { + public void draw(Canvas canvas, int width, int height) { if (mCursorVisible) { - canvas.drawLine(new Point(mPosX, 0), new Point(mPosX,height), mPaintLine); + canvas.drawLine(new Point(mPosX, 0), new Point(mPosX, height), mPaintLine); } // selection @@ -208,7 +208,11 @@ public class CursorMode { } public void setTextSize(float t) { - mStyles.textSize = t; + if (t <= 0) { + mStyles.textSize = 20; + } else { + mStyles.textSize = t; + } } public void setTextColor(int color) { diff --git a/graphveiw/src/main/java/com/jjoe64/graphview/GridLabelRenderer.java b/graphveiw/src/main/java/com/jjoe64/graphview/GridLabelRenderer.java index da460dc9660cdce49c013fbcf27aafa92aa3daa5..af838135d51f9231358f4d2b89779ffdc359ea4d 100644 --- a/graphveiw/src/main/java/com/jjoe64/graphview/GridLabelRenderer.java +++ b/graphveiw/src/main/java/com/jjoe64/graphview/GridLabelRenderer.java @@ -1383,7 +1383,7 @@ public class GridLabelRenderer { float y = posY; - String label = mLabelFormatter.formatLabel(e.getValue().intValue(), false); + String label = mLabelFormatter.formatLabel(e.getValue(), false); LogUtil.error("yuxh--verticalLabel--->", label + "~~~" + e.getValue().intValue()); if (label == null) { label = ""; @@ -1548,7 +1548,11 @@ public class GridLabelRenderer { * and {@link #setHorizontalAxisTitleTextSize(float)} */ public void setTextSize(float textSize) { - mStyles.textSize = textSize; + if (textSize <= 0) { + mStyles.textSize = 20; + } else { + mStyles.textSize = textSize; + } reloadStyles(); } @@ -1693,7 +1697,12 @@ public class GridLabelRenderer { * @param verticalAxisTitleTextSize font size of the vertical axis title */ public void setVerticalAxisTitleTextSize(float verticalAxisTitleTextSize) { - mStyles.verticalAxisTitleTextSize = verticalAxisTitleTextSize; + if (verticalAxisTitleTextSize <= 0) { + mStyles.verticalAxisTitleTextSize = 20; + } else { + mStyles.verticalAxisTitleTextSize = verticalAxisTitleTextSize; + } + } /** diff --git a/graphveiw/src/main/java/com/jjoe64/graphview/Viewport.java b/graphveiw/src/main/java/com/jjoe64/graphview/Viewport.java index 4dcf918d60a43a4a1313b8fb3b5696e468be237d..a7fcd828a159df32db58ead9e20efdac656c605a 100644 --- a/graphveiw/src/main/java/com/jjoe64/graphview/Viewport.java +++ b/graphveiw/src/main/java/com/jjoe64/graphview/Viewport.java @@ -319,7 +319,7 @@ public class Viewport { * @return true if it was consumed */ public boolean onTouchEvent(TouchEvent event) { - boolean b = false; + boolean b = true; // b |= mGestureDetector.onTouchEvent(event); if (mGraphView.isCursorMode()) { if (event.getAction() == TouchEvent.PRIMARY_POINT_DOWN) { diff --git a/graphveiw/src/main/java/com/jjoe64/graphview/helper/GraphViewXML.java b/graphveiw/src/main/java/com/jjoe64/graphview/helper/GraphViewXML.java index 5c703b16bda1ec73199d9b6f6ccf9c03e8c5a010..7e12bb6a796dded7f8c6cacb04d66cc8b7ba5735 100644 --- a/graphveiw/src/main/java/com/jjoe64/graphview/helper/GraphViewXML.java +++ b/graphveiw/src/main/java/com/jjoe64/graphview/helper/GraphViewXML.java @@ -22,6 +22,8 @@ import com.jjoe64.graphview.utils.LogUtil; import ohos.agp.components.AttrSet; import ohos.agp.utils.Color; import ohos.app.Context; +import ohos.eventhandler.EventHandler; +import ohos.eventhandler.EventRunner; import static com.jjoe64.graphview.utils.AttrSetString.*; @@ -80,9 +82,9 @@ public class GraphViewXML extends GraphView { // decode data - DataPoint[] data; + DataPoint[] data = new DataPoint[0]; if (dataStr == null || dataStr.isEmpty()) { - throw new IllegalArgumentException("Attribute seriesData is required in the format: 0=5.0;1=5;2=4;3=9"); + throwSleepTime("Attribute seriesData is required in the format: 0=5.0;1=5;2=4;3=9"); } else { String[] d = dataStr.split(";"); try { @@ -96,13 +98,12 @@ public class GraphViewXML extends GraphView { LogUtil.info(TAG, Double.parseDouble(xy[0]) + "~~~" + Double.parseDouble(xy[1])); } } catch (Exception e) { - LogUtil.error("GraphViewXML", e.toString()); - throw new IllegalArgumentException("Attribute seriesData is broken. Use this format: 0=5.0;1=5;2=4;3=9"); + throwSleepTime("Attribute seriesData is broken. Use this format: 0=5.0;1=5;2=4;3=9"); } } // create series - BaseSeries series; + BaseSeries series = null; if (type == null || type.isEmpty()) { type = "line"; } @@ -113,8 +114,7 @@ public class GraphViewXML extends GraphView { } else if (type.equals("points")) { series = new PointsGraphSeries(data); } else { - LogUtil.error("unknown graph type: " + type , ". Possible is line|bar|points"); - throw new IllegalArgumentException("unknown graph type: " + type + ". Possible is line|bar|points"); + throwSleepTime("unknown graph type: " + type + ". Possible is line|bar|points"); } if (color.getValue() != 0) { series.setColor(color.getValue()); @@ -130,4 +130,14 @@ public class GraphViewXML extends GraphView { setTitle(title); } } + + private void throwSleepTime(String str){ + new EventHandler(EventRunner.create()).postTask(new Runnable() { + @Override + public void run() { + throw new IllegalArgumentException(str); + + } + },500); + } }