【发布时间】:2015-02-12 17:33:58
【问题描述】:
我正在尝试在 Android(Java 版本)上的 TeeChart 中添加一个 ColorLine 工具。 一切正常,只是我无法使用 DASH 样式绘制线条。
这是我的代码 sn-p:
ColorLine closeLabelLine = new ColorLine(chart.getChart());
closeLabelLine.setValue(closeValue);
closeLabelLine.setAxis(chart.getAxes().getRight());
closeLabelLine.getPen().setStyle(DashStyle.DASH); //Seems like no effect!
closeLabelLine.getPen().setColor(CLOSE_LABEL_COLOR);
我做错了什么?
更新:
通过设置 chart.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 和 closeLabelLine.setDraw3D(false); 测试 Yeray 的解决方案后,一切似乎都正常工作。但是在添加轴中断工具后,我遇到了以下异常:
java.lang.IllegalStateException: Underflow in restore
at android.graphics.Canvas.native_restore(Native Method)
at android.graphics.Canvas.restore(Canvas.java:497)
at com.steema.teechart.android.Graphics3DAndroid.restore(Graphics3DAndroid.java:356)
at com.steema.teechart.android.Graphics3DAndroid.unClip(Graphics3DAndroid.java:362)
at com.steema.teechart.tools.AxisBreaksTool.drawRectangle(AxisBreaksTool.java:410)
at com.steema.teechart.tools.AxisBreaksTool.doDrawLine(AxisBreaksTool.java:720)
at com.steema.teechart.tools.AxisBreaksTool.chartEvent(AxisBreaksTool.java:748)
at com.steema.teechart.Chart.broadcastToolEvent(Chart.java:1035)
at com.steema.teechart.Chart.drawAllSeries(Chart.java:813)
at com.steema.teechart.Chart.drawAxesSeries(Chart.java:802)
at com.steema.teechart.Chart.internalDraw(Chart.java:782)
at com.steema.teechart.Chart.paint(Chart.java:2169)
at com.steema.teechart.Chart.paint(Chart.java:2185)
at com.steema.teechart.TChart.onDraw(TChart.java:326)
at android.view.View.draw(View.java:15114)
at android.view.View.buildDrawingCache(View.java:14343)
at android.view.View.updateDisplayListIfDirty(View.java:14029)
at android.view.View.getDisplayList(View.java:14071)
at android.view.View.draw(View.java:14838)
at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.updateDisplayListIfDirty(View.java:14043)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
at android.view.View.updateDisplayListIfDirty(View.java:14008)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
我发现chart.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 会导致图表正常工作,但 ColorLine 显示为实线,而不是所需的破折号。
【问题讨论】: