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

  • SEARCH
  • Home
  • 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 3615010
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:19:13+00:00 2026-05-18T22:19:13+00:00

I am trying to create a scatter chart on my web page with CSS

  • 0

I am trying to create a scatter chart on my web page with CSS and few dots images. I have created the design successfully, but now I can’t figure out how a scatter chart actually works. Can anyone provide me any idea how I can arrange them? My chart width is 968 and height 432.
like this chart

http://chart.apis.google.com/chart?cht=s&chd=t:12,16,16,24,26,28,41,51,66,68,13,45,81|16,14,22,34,22,31,31,48,71,64,15,38,84&chs=250×100&chl=Hello|World

i cannot use this but i want to know how it works

Thanks for any help.

<?php
$w = 968; $h = 432;
$xmin = 0; $xmax = 968;
$ymin = 10; $ymax = 100;
$x = 10; $y = 10;
$xc = 20;
$yc = 20;
$r = (20)/ 2;
 $xc = $w * (($x - $xmin)/($xmax - $xmin)) - $r . "<br>";
$yc = $h * (($ymax - $y)/($ymax - $ymin)) -$r;
$tr ='';
$data = array("120|90","345|456","45|66","45|45");
foreach($data as $value){
    $new =  explode("|",$value);
    $tr .='<a href="#" style="top:'.$new[0].'px; left:'.$new[1].'px;" class="dot"></a>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

    <style type="text/css">
#most_engaged_graph{
width:968px;
height:432px;
background-color:#CCCCCC;
}
a.dot {
 height:20px;
 width:20px;
 position:absolute;
 background-color:#0033FF;
}
</style>  
</head>
<body>
<div id="most_engaged_graph"> 
<?=$tr?>   
</div>
</body>
</html>
  • 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-18T22:19:13+00:00Added an answer on May 18, 2026 at 10:19 pm

    Well your dot pitch is 20px square, and you need to position them on the graph with the bottom left corner as the origin (0,0).

    You need to know the scale of the axis, which you have not stated. Decide how many pixels per distance upon your axis.

    Then you need to convert the position you desire of each point P(x,y), to a position on the screen. You want the centre pixel of your .dot to be at that location.

    As the screen coordinate run from top-left, not bottom-left, you will need to reverse the vertical pixels, so maximum is zero, and zero (or full negative) is the height of the graph, plus/minus half the size of your dot in both cases.

    Given:

    • W = graph width (px), H = graph height (px)
    • Xmin = minimum x axis, Xmax = maximum x axis
    • Ymin = minimum y axis, Ymax = maximum y axis
    • x = x value on graph (Xmin <= x <= Xmax), y = y value on graph (Ymin <= y <= Ymax)
    • Xc = x-center of dot, Yc = y-center of dot
    • r = dot radius = (dot width) / 2

    Then:

    • Xc = W * [(x - Xmin)/(Xmax - Xmin)], Yc = H * [(Ymax - y)/(Ymax - Ymin)]
    • left = Xc - r, top = Yc - r

    Untested, I think that is right – might need adjustment. In particular, subtract 2r from W and H if you need the dots to appear fully within the area (that applies to the whole of the graph, axis et al).


    Example code:

    <div id="most_engaged_graph"> 
    <?php
    $dataPoints = array(
                        array('x' => 5, 'y' => 20),
                        array('x' => 80, 'y' => 50),
                        array('x' => 45, 'y' => 5),
                        array('x' => 68, 'y' => 89),
                        array('x' => 22, 'y' => 43)
                  );
    
    foreach ($dataPoints as $cPoint) {
        // Assuming $w, $h, $xmin, $ymin, $xmax, $ymax, $r are defined above
        $xc = $w * (($cPoint['x'] - $xmin) / ($xmax - $xmin));
        $yc = $h * (($ymax - $cPoint['y']) / ($ymax - $ymin));
    
        $cLeft = $xc - $r;
        $cTop  = $yc - $r;
    ?>
        <a href="#" style="top: <?php echo $cTop; ?>px; left: <?php echo $cLeft; ?>px;" class="dot"></a>
    <?php
    }
    ?>
    </div>
    

    jQuery version Demo: http://jsfiddle.net/75Mz5/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying create a class derivated from System.Web.UI.Page and in override Render i set
I am trying create a new css for shaping my detailsview. But i couldn't
Trying to create a user account in a test. But getting a Object reference
I'm trying to create a sitemap using Linq to Xml, but am getting an
I'm a bit of newbie at this and am trying to create a scatter
Im trying to create a array of Checkboxes in Winforms and I have four
Im trying to create LinqDataSource that will represent data from dynamically created String list
I am trying create a data.frame from which to create a graph. I have
I am trying create alert dailog using glade,but its not working .am i doing
I am trying create a WCF service that leverages the WPF MediaPlayer on the

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.