FLEX:使 LineChart DATATIP 约束到垂直轴

发布于 2024-07-13 22:18:47 字数 445 浏览 10 评论 0原文

在制作折线图时,可以说它是不同部门的业务销售额,水平方向是天数,垂直方向是美元。 当您将鼠标悬停在一行上时,它会显示一个数据提示,告诉您该部门的销售额。 在那一天。 我希望它同时显示所有部门,所以假设您将鼠标悬停在第 3 天,我希望显示第 3 天所有部门的数据提示,以便您可以比较同一天所有销售额的值。 我为数据提示设置了 mouseSensitivity 以一次显示所有行,但最终我得到了一个部门的第 2 天和另一个部门的第 3 天,这是不需要的。 这实际上是作为错误发布的,并在此处进行了更好的解释:http://bugs.adobe。 com/jira/browse/FLEXDMV-1853

我想知道是否有人可以为此想出解决方法?

谢谢!

When making a line chart, Lets say its for business sales for different depts and horizontally is days and vertically is dollars. When you hover over a line it tells a dataTip tells you the sales for that dept. on that day. I want it to show all the depts at the same time, so say you hover over day 3, I want the dataTips for all depts on day 3 to display so you can compare the values for all the sales on the same day. I set the mouseSensitivity for the dataTips to display all the lines at once but I end up getting day 2 for one dept and day 3 for another which is not wanted. This is actually posted as a bug and explained better here: http://bugs.adobe.com/jira/browse/FLEXDMV-1853

I am wondering if anyone can come up with a work-around for this?

Thanks!

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

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

发布评论

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

评论(3

终难遇 2024-07-20 22:18:47

我最近遇到了与此类似的问题,并提出了一个也适用于您的问题的解决方案。 我有一个步骤折线图,希望当用户将鼠标悬停在线上的任意位置而不是仅在定义的数据点时显示数据提示。

您可以在此处阅读我针对该问题编写的解决方案: Flex:自定义折线图中的数据提示位置和行为

您必须稍微修改我的解决方案以适应您的问题:

在第 47 行,您可以删除 Math.abs (last.y - mouseLoc.y) < 50 检查。 这将数据提示限制为鼠标垂直方向 50 像素以内的线条。

我假设您使用的是默认的线段折线图,它只是直接在数据点之间绘制线条。 您需要修改计算给定 x 坐标处的线值的代码才能使用该图表类型。 我已经在第 33-41 行找到距离鼠标左侧最近的数据点,并将其存储在 last 中。 只需获取下一个数据点(这将是最接近鼠标右侧的数据点)并使用类似的方法来获取鼠标处的值:

var slope:Number = (nextPoint.y - last.y) / (nextPoint.x - last.x);
var lineYAtMouse:Number = (slope * (last.x - mouseLoc.x)) + last.y;
var lineValue:Array = line.localToData(new Point(mouseLoc.x, lineYAtMouse));

然后将第 69 行到 72 行替换为:

hitPoint.x = mouseLoc.x;
hitPoint.y = lineYAtMouse;
hitPoint.xValue = lineValue[0];
hitPoint.yValue = lineValue[1];

我还没有没有测试这些修改,因此可能存在一个或两个错误,但总体思路是存在的。 我希望这对某人仍然有用。 这个问题已经很老了。 :)

I ran into a similar problem to this recently and came up with a solution that also applies to your problem. I had a step LineChart and wanted to display a data tip when the user hovered anywhere on the line instead of just at defined data points.

You can read about the solution I wrote for that problem here: Flex: Customizing data tip location and behavior in a LineChart

You'll have to modify my solution slightly to fit your problem:

On line 47 you can remove the Math.abs(last.y - mouseLoc.y) < 50 check. This constrains the data tips to lines that are within 50 pixels vertically of the mouse.

I'm assuming that you're using the default segment line chart which just draws lines directly between data points. You'll need to modify the code that calculates the line value at a given x-coordinate to work with that chart type. I already find the closest data point to the left of the mouse with lines 33-41 and store it in last. Just get the next data point (which will be the one closest to the right of the mouse) and use something like this to get the value at the mouse:

var slope:Number = (nextPoint.y - last.y) / (nextPoint.x - last.x);
var lineYAtMouse:Number = (slope * (last.x - mouseLoc.x)) + last.y;
var lineValue:Array = line.localToData(new Point(mouseLoc.x, lineYAtMouse));

Then replace lines 69 through 72 with:

hitPoint.x = mouseLoc.x;
hitPoint.y = lineYAtMouse;
hitPoint.xValue = lineValue[0];
hitPoint.yValue = lineValue[1];

I haven't tested these modifications so there could be a bug or 2 but the general idea is there. I hope maybe this is still useful to someone. This question is getting pretty old. :)

╭⌒浅淡时光〆 2024-07-20 22:18:47

这不是一个答案,而是一个糟糕的替代方案:

您可以创建自己的 DataTip 渲染器,[咳咳]映射每个点的位置并为每个点绘制提示。

基本上,您将在图表类中复制大量代码。

Not an answer, but a poor alternative:

You could create your own DataTip renderer that [ahem] mapped the location of every point and drew the tip for each one there.

Basically, you would be duplicating a lot of the code inside the charting classes.

小傻瓜 2024-07-20 22:18:47

我有同样的问题,但正在处理柱形图。 我想我可以使用backgroundElements启用垂直网格线,然后添加一个用于鼠标悬停的图表事件侦听器(当鼠标经过垂直网格线时触发)。 使用 localX 值,我可以将其与最近的数据点进行比较。

布莱恩

I have the same problem but working on column charts. Was thinking that I could enable the vertical gridLines using backgroundElements and then add a chart event listener for mouse over (which fires when mouse passes over a vertical gridline). Using the localX value, i could compare it to the closest datapoint, maybe.

Brian

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