gpt4 book ai didi

java - 如何在TeeChart中用DASH风格绘制ColorLine?

转载 作者:行者123 更新时间:2023-12-02 05:02:04 28 4
gpt4 key购买 nike

我正在尝试将 ColorLine 工具添加到 Android(Java 版本)上的 TeeChart。一切工作正常,除了我无法用 DASH 风格绘制线条。

这是我的代码 fragment :

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 显示为实线,而不是所需的破折号。

最佳答案

有两个提示可以帮助您获得所需的结果:

  • 第一个注释 thisthis 。如果您想绘制 DASH 线,则必须从 API 11 禁用硬件加速:

    if (Build.VERSION.SDK_INT>10)
    chart.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  • 另请注意,ColorLine 工具默认绘制侧面和背面。要禁用此功能并仅绘制前线:

    closeLabelLine.setDraw3D(false);
<小时/>

更新:

正如您在问题的更新部分中所说,使用建议的修复在使用AxisBreaksTool时会产生错误。
实际上,我发现在剪辑某些内部函数时缺少对 canvas.save() 的一些调用,从而产生此崩溃以及其他崩溃。
我已在内部源中添加了所需的调用,它似乎对我来说工作正常。
但是,我无法考虑使其在当前版本中工作的解决方法,因此恐怕您将不得不等待下一个维护版本(您可以发送邮件到“info at steema dot com”要求测试发布)。

<小时/>

更新2:

我最初修改了 TeeChart 源,以便在笔设置为 DASH 样式时在内部禁用硬件加速。但是 setLayerType 是 implemented in API 11因此,为了保持 API 7 对 TeeChart 的支持,我必须将其删除并让开发人员在必要时执行此操作。

关于java - 如何在TeeChart中用DASH风格绘制ColorLine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28176570/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com