4 Replies Latest reply on Mar 8, 2013 7:20 PM by Ravi Ramineni

    How can i plot lines between 2 points (x1,y1) and (x2,y2)?

    Ravi Ramineni

      Each row of my file have the columns, x1,y1,x2,y2.

      Is there a way I can draw line connecting the two points?

       

      Thanks

      Ravi

        • 1. Re: How can i plot lines between 2 points (x1,y1) and (x2,y2)?
          Joshua Milligan

          Is there any way you can reshape your data?  The reason for this is that to draw a line between two points is relatively easy if the source and destination points are two different records.

           

          Even if you could just union a duplicate your data together like this:

           

          SELECT 'source' as Type, ID, X1 as X, Y1 as Y

          UNION ALL

          SELECT 'dest' as Type, ID, X2 as X, Y2 as Y

           

          Then, using the line mark, you would be able to put Type on the Path shelf and ID in the level of detail.

           

          Regards,

          Joshua

          • 2. Re: How can i plot lines between 2 points (x1,y1) and (x2,y2)?
            Ravi Ramineni

            Thanks Joshua.
            Not sure I fully understand the duplication process. Can you give a more concrete example? I have attached a test file of my data.

            I want to draw lines between X,Y and EndX, EndY

            • 3. Re: How can i plot lines between 2 points (x1,y1) and (x2,y2)?
              Joshua Milligan

              Ravi,

               

              I took your data and added a UniqueID for each record.  That's the only thing it was missing that is needed for this approach to work.

               

              Then I used the Custom SQL option for the data connection (see image below and SQL below).

               

              I've attached the workbook so you can see it in action.

               

              Regards,

              Joshua

               

              connection.png

               

               

              Custom SQL:

               

              SELECT [testfile#csv].[Action] AS [Action],

                [testfile#csv].[EventID] AS [EventID],

                [testfile#csv].[FirstName] AS [FirstName],

                [testfile#csv].[LastName] AS [LastName],

                [testfile#csv].[Minutes] AS [Minutes],

                [testfile#csv].[PrevFirstName] AS [PrevFirstName],

                [testfile#csv].[PrevLastName] AS [PrevLastName],

                [testfile#csv].[Seconds] AS [Seconds],

                [testfile#csv].[Success] AS [Success],

                [testfile#csv].[TimeStamp] AS [TimeStamp],

                [testfile#csv].[UniqueID] AS [UniqueID],

              'source' AS [Type],

                [testfile#csv].[X] AS [X],

                [testfile#csv].[Y] AS [Y]

              FROM [testfile#csv]

              UNION

              SELECT [testfile#csv].[Action] AS [Action],

                [testfile#csv].[EventID] AS [EventID],

                [testfile#csv].[FirstName] AS [FirstName],

                [testfile#csv].[LastName] AS [LastName],

                [testfile#csv].[Minutes] AS [Minutes],

                [testfile#csv].[PrevFirstName] AS [PrevFirstName],

                [testfile#csv].[PrevLastName] AS [PrevLastName],

                [testfile#csv].[Seconds] AS [Seconds],

                [testfile#csv].[Success] AS [Success],

                [testfile#csv].[TimeStamp] AS [TimeStamp],

                [testfile#csv].[UniqueID] AS [UniqueID],

              'destination' AS [Type],

                [testfile#csv].[EndX] AS [X],

                [testfile#csv].[EndY] AS [Y]

              FROM [testfile#csv]