D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
dougdowson
Full window
Github gist
Scatterplot: Income Inequality
<!DOCTYPE HTML> <meta charset="utf-8"> <html> <head> <script src="https://d3js.org/d3.v3.min.js"></script> <link rel="stylesheet" href="https://cdn.static-economist.com/sites/all/themes/econfinal/styles/reset.css"> <link type="text/css" rel="stylesheet" media="all" href="https://cdn.static-economist.com/sites/all/themes/econfinal/styles/ec-custom-fonts.css"> <style> body, h1, h2, h3, p, table, td { margin: 0px; padding: 0px; font-family: Arial, sans-serif; font-size: 13px; line-height: 1.5em; color: #000; } #content { margin: 0px; padding: 0px; width: 595px; text-align: left; } #container { margin: 0px 0px 15px 0px; padding: 0px; } #header h1 { margin: 8px 0px 0px 20px; padding: 0px; font-family: Officina_bold, Calibri, Arial; font-size: 17px; font-weight: normal; color: #000; } p { margin: 0px 0px 15px 0px; color: #4a4a4a; font-weight: normal; font-family: Arial,sans-serif; } g.y.axis path.domain { stroke-width: 0px; } g.x.axis path.domain, g.x.axis g.tick.major line, g.x.axis g.tick line { stroke: #333; stroke-width: 1px; shape-rendering: crispEdges; } .axis path, .axis line { fill: none; shape-rendering: crispEdges; } .axis line { stroke: #eee; stroke-width: 1px; } g.group text, g.tick text, .x.axis text { font-family: Officina, Calibri, Arial; font-size: 13px; } #buttons { margin: 10px 5px 0px 0px; padding: 0px; float: right; } .button { display: inline-block; margin: 0px; padding: 2px 5px; line-height: 20px; text-align: center; font-family: Officina, Calibri, Arial; font-size: 14px; display: inline-block; cursor: pointer; border: 1px solid #E30010; margin-right: -5px; } #buttons .selected { background: #ff0000; color: #fff; } .button:hover { background:#ff0000; color: #fff; cursor: pointer; } #header { margin: 0px; padding: 0px; border: 1px solid #E11B17; border-width: 2px 0px 0px 0px; } #block { float: left; margin: 0px; padding: 0px; height: 25px; width: 10px; background: #E11B17; } .left.label { font-family: Officina, Calibri, Arial; font-size: 13px; fill: #000; } g.group text { opacity: 0; } circle { fill: #00a1ce; stroke: #fff; stroke-width: 1.5; } .scatter { opacity: 0.6; } .trendline { fill: none; stroke: #772210; stroke-width: 2px; opacity: 0.8; } rect { fill: #ccc; } div.tooltip { position: absolute; pointer-events: none; margin: 0px; padding: 7px; background: #fff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border: 1px solid #ccc; opacity: 0; display: none; } div.tooltip p, div.tooltip h2 { margin: 0px; padding: 0px; font-size: 13px; line-height: 1.2rem; color: #000; text-align: left; font-family: Officina, Calibri, Arial; font-size: 13px; } div.tooltip h2 { margin: 0px; padding: 0px 0px 5px 0px; font-size: 14px; } .legend circle { fill: none; stroke: #ccc; stroke-width: 1; } .legend text { fill: #747474; font-family: Officina, Calibri, Arial; font-size: 12px; text-anchor: middle; } .t-container { margin: 0px 0px 15px 0px; padding: 0px; height: 492px; overflow-y: scroll; } .t-title { color: #000; line-height: 1.15em; margin: 0px; padding: 0px; } .t-container .t-title { font-size: 12px; font-weight: bold; height: 4em; position: relative; width: 90px; } .t-container .t-title > div { position: absolute; width: 90px; bottom: 5px; color: #fff; font-weight: normal; } .t-container .g-ascending:after, .t-container .g-descending:after { top: 30px; left: 35px; color: #fff; font-size: 10px; position: relative; } .first-column .g-ascending:after, .first-column .g-descending:after { left: 100px; } .t-container .t-column:first-child .g-descending:after, .t-container .g-ascending:after { content: '\25BC'; } .t-container .t-column:first-child .g-ascending:after, .t-container .g-descending:after { content: '\25B2'; } .t-column { background: #747474; color: #fff; display: inline-block; width: 90px; margin: 0px; text-align: center; vertical-align: middle; padding: 0px; border: 1px solid #ccc; border-width: 0px 1px 1px 0px; font-size: 12px; } .t-cell { display: inline-block; width: 90px; height: 100%; text-align: center; vertical-align: middle; border: 1px solid #fff; border-width: 0px 1px 0px 0px; font-size: 95%; } .first-column { width: 117px; text-align: left; padding: 0px 0px 0px 5px; } #table .t-row .first-column { padding: 0px 0px 0px 5px; } .t-row { border: 1px solid #fff; border-width: 0px 0px 1px 0px; } table { border-spacing: 0; border-collapse: collapse; } .t-column:hover { cursor: pointer; background: #454545; } #chart { margin: 0px; padding: 0px 0px 0px 20px; } #source, #note { margin: -5px 0px 0px 20px; padding: 0px; font-family: Officina, Calibri, Arial; font-size: 13px; color: #000; } #source { margin: 0px 0px 0px 20px; padding: 0px; } #note { display: inline; text-align: right; float: right; margin: 0px; } #select { margin: 10px 0px 0px 20px; } #selectMenu option { opacity: 0.8; } @-moz-document url-prefix() { .t-column { margin: 0px -4px 0px 0px; } } </style> </head> <body> <div id="content"> <div id="buttons"> <div class="button selected" id="switchMajor">General occupations</div> <div class="button" id="switchDetailed">Specific jobs*</div> </div> <div id="header"> <div id="block"></div> <h1>America's income growth</h1> </div> <div id="select"> <select id="selectMenu" onchange="highlight()"> <option value="scatter">All occupations</option> <option value="code370000">Building and grounds cleaning and maintenance</option> <option value="code130000">Business and financial operations</option> <option value="code470000">Construction and extraction</option> <option value="code250000">Education, training, and library</option> <option value="code350000">Food preparation and serving related</option> <option value="code290000">Healthcare practitioners and technical</option> <option value="code310000">Healthcare support</option> <option value="code490000">Installation, maintenance, and repair</option> <option value="code110000">Management</option> <option value="code430000">Office and administrative support</option> <option value="code390000">Personal care and service</option> <option value="code510000">Production</option> <option value="code330000">Protective service</option> <option value="code410000">Sales and related</option> <option value="code530000">Transportation and material moving</option> </select> </div> <div id="container"> <div id="chart"></div> <p id="note">*With at least 100,000 workers</p> <p id="source">Source: U.S. Bureau of Labour Statistics</p> </div> </div> <script type="text/javascript" src="chart.js"></script> </body> </html>
Modified
http://d3js.org/d3.v3.min.js
to a secure url
https://d3js.org/d3.v3.min.js