Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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.</p> <p>You can read about the solution I wrote for that problem here: <a href="http://instantdelay.com/2010/08/flex-customizing-data-tip-location-and-behavior-in-a-linechart/" rel="nofollow noreferrer">Flex: Customizing data tip location and behavior in a LineChart</a></p> <p>You'll have to modify my solution slightly to fit your problem:</p> <p>On line 47 you can remove the <code>Math.abs(last.y - mouseLoc.y) &lt; 50</code> check. This constrains the data tips to lines that are within 50 pixels vertically of the mouse.</p> <p>I'm assuming that you're using the default <em>segment</em> 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 <code>last</code>. Just get the next data point (which will be the one closest to the <em>right</em> of the mouse) and use something like this to get the value at the mouse:</p> <pre><code>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)); </code></pre> <p>Then replace lines 69 through 72 with:</p> <pre><code>hitPoint.x = mouseLoc.x; hitPoint.y = lineYAtMouse; hitPoint.xValue = lineValue[0]; hitPoint.yValue = lineValue[1]; </code></pre> <p>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. :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload