Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:10:33+00:00 2026-05-31T06:10:33+00:00

I am reading a JSON file and foreach element I am creating a path

  • 0

I am reading a JSON file and foreach element I am creating a path and a circle. I need to make the path drag with the circle. The path terminates at the exact x,y coordinates of the circle center. I only want the circle end of the path to drag with the circle. The other end of the path is fixed.

I have drag working for the circles but it is not doing anything for the paths. I have posted code that is dumbed down and does not contain the intelligence for positioning circles. I only need help with dragging one end of the path. My script is reading the JSON fine and painting the canvas with circles and paths at the correct coordinates. Thanks in advance for your help.

I do not answers that require an additional plug in please.

<script type="text/javascript">

$.getJSON('jsonScript.php?view=json', function( json ){

 var start = function () {
       this.ox = this.attr("cx");
       this.oy = this.attr("cy");
       this.animate();
     },
     move = function (dx, dy) {
             this.attr({cx: this.ox + dx, cy: this.oy + dy});
     },
     up = function () {
             this.animate();
  };

  var paper = Raphael( canvas.leftMargin, canvas.topMargin, canvas.width, canvas.height );

  $.each( json, function( a , z ) {

    var circleObj = paper.circle( x, y, radius );
    circleObj.attr({"fill":"black","stroke":"red","stroke-width":5});
    circleObj.node.id = jsonVar;

    var pathObj = paper.path( "M396,16L641,187" );
    path.attr({"stroke":"#fdfdfd","stroke-width":3}).toBack();

    paper.set( circleObj, pathObj ).drag( move, start, up ) 

  });
});

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:10:34+00:00Added an answer on May 31, 2026 at 6:10 am

    You can attach path to circleObject by just assigning it within your .each block…

    $.each(json, function(a, z) {
      ...
      circleObject.path = path;
    });
    

    This way you can access it from within the start, up and move functions…

     move = function (dx, dy) {
             this.path.attr(path)[1][1] = this.ox + dx;
             this.path.attr(path)[1][2] = this.oy + dy;
     },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try reading a JSON file from R using rjson but keep getting errors.
I get the following error when reading in a text file of raw JSON
I am reading data from a json file and the titles of the key/value
I'm reading a JSON file with jQuery. If I update the file that .get()
I'm reading the json output from this file and have the decoded json stored
I'm reading JSON data with PHP and that data contains empty objects (like {}
I'm reading an array of JSON objects from an API, and hope to use
I was doing Json parsing. As of now, I was reading it from a
I have a json file which contains questions and answers like this. { Questions:
I'm opening a JSON file and decoding the content of it, so I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.