1 Reply Latest reply on Apr 18, 2008 12:19 AM by jbucaran

    Flex Chart Region Selection Coordinates

    jbucaran
      This applies to Flex Chart controls.

      Is it possible to get the rectangular coordinates of a selected region?

      I am not interested in the selected items, but rather, the rectangular coordinates of the selected region.

      Do I need to apply any system transformations?

      In any case, how do I accomplish this?

      Jorge Bucaran
      Venezuela
        • 1. Re: Flex Chart Region Selection Coordinates
          jbucaran Level 1
          OK,

          Here is how, attach a mouseUp event to the chart or chartSeries control...

          private function mouseUp(event:MouseEvent):void {
          var pt1:Point = new Point();
          var coordinates:Array = chartSeries.localToData(
          new Point(chart.mouseX,chart.mouseY));
          this.pt1.x = Math.floor(coordinates[0]);
          this.pt1.y = Math.floor(coordinates[1]);

          Alert.show(pt1.toString());
          }

          However the results are innacurate for 2 pixels... :(

          What really makes me sad is that if you use:

          private function mouseUp(event:MouseEvent):void {
          var pt1:Point = new Point();
          var coordinates:Array = chart.localToData(
          new Point(chart.mouseX,chart.mouseY));
          this.pt1.x = Math.floor(coordinates[0]);
          this.pt1.y = Math.floor(coordinates[1]);

          Alert.show(pt1.toString());
          }

          Note that I am calling localToData from the chart control, which is deprecated.

          It works in this way...

          So what's the solution? The one that works is deprecated, the one that's suppose to work does not!

          Or maybe I am doing something wrong here...

          I need to figure this out...