Flex:使用自定义 LineSeries,以便项目渲染/数据提示仍然有效

发布于 2024-11-19 20:11:15 字数 1055 浏览 0 评论 0原文

简要说明:如果我创建一个自定义的 LineSeries 类并将其添加到我的项目中,即使它与原始类相同,我也会失去数据提示功能。

详细描述: 我正在使用 LineChart 组件,我需要渲染线条,以便它们根据某些值范围改变颜色。所以我修改了 LineRenderer,将其应用到我的 LineSeries 中,一切都运行良好。不幸的是,我后来意识到我需要动态提供范围和颜色,因为它们应该是可定制的。这就是棘手的地方。

这是我用来设置 lineRenderer 的代码:

var cf:ClassFactory = new ClassFactory(myLineRenderer);
lineSeries.setStyle("lineSegmentRenderer",cf);

我没有找到一种在不创建 ClassFactory 实例的情况下动态更改 ClassFactory 上的数据的方法。但如果我创建它的实例,我无法将其设置为样式。如果有人知道如何做到这一点,它将直接解决我的问题。我需要的只是在 myLineRenderer 中设置一个数组属性。但我明白为什么这不能做到。 我可以动态创建一个新类,它是 myLineRederer 的克隆,但更改了一个属性吗? 我可以向 myLineRenderer 构造函数添加参数吗?如果是这样,上面的代码将如何工作?

无论如何,由于这不起作用,我认为我需要更改提供给 myLineRenderer 的数据。为此,我创建了自己的 LineSeries,它具有一个可设置的 Array 属性,它将添加到传递给 myLineRenderer 的数据中。而且效果很好。有一点小问题。一旦我将 LineChart 系列从 LineSeries 更改为 myLineSeries,我就无法沿线移动鼠标光标并获取图表中每个项目的信息。我删除了对原始 LineSeries 所做的所有更改,但这没有什么区别。我缺少什么?

现在,我陷入了没有数据提示的可自定义颜色范围和有数据提示的不可自定义颜色范围之间。前者仍然更好,但我真的需要两者都能工作,或者至少知道为什么这是不可能的。

任何帮助将不胜感激。

Brief description: If I create a customized LineSeries class and add that one to my project, even if it's the same as original, I lose data tip functionality.

Elaborated description:
I'm using a LineChart component and I needed to render my lines so that they change color according to some value ranges. So I modified LineRenderer, applied it to my LineSeries and everything was working great. Unfortunately I later realized that I will need to supply ranges and colors dynamically as they're supposed to be customizable. This is where it gets tricky.

This is the code I use to set my lineRenderer:

var cf:ClassFactory = new ClassFactory(myLineRenderer);
lineSeries.setStyle("lineSegmentRenderer",cf);

I did not find a way to dynamically change data on a ClassFactory without making an instance of it. But if I make an instance of it, I can not set it as a style. If anyone knows of a way to do this, it would solve my problem straight out. All I need is to set an array property inside myLineRenderer. But it makes sense to me why this can't be done.
Can I dynamically make a new Class that is a clone of myLineRederer yet has one property changed?
Can I add an argument to myLineRenderer constructor? If so, how would that work with the code above?

Anyway, since that didn't work, I figured I needed to change the data supplied to myLineRenderer. For this I created my own LineSeries that has a settable Array property that it adds to the data passed to myLineRenderer. And it works great. With one little kink. As soon as I change my LineChart series from LineSeries to myLineSeries, I can't move the mouse cursor along the line and get info on each item in the chart. I removed all the changes I made to original LineSeries, but it makes no difference. What am I missing?

Right now I'm trapped between having customizable color ranges with no data tips and non-customizable color ranges with data tips. The former is still better, but I would really need both to work or at least know why that's impossible.

Any help would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

下壹個目標 2024-11-26 20:11:15

看一下 ClassFactoryproperties 属性

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html#properties

我认为这正是您所需要的。

Take a look at the properties property of ClassFactory

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html#properties

I think that does exactly what you need it to.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文