I have the following code snippet:
var data = [{ "Part": 956, "Pos": "P2", "Side": "A", "Number": 1, "PIN/PAD": "A1", "xdim": 0.022, "ydim": 0.08, "centrex": 1.775685039, "centrey": 0.1945, "Rotated": "TRUE" }]; var svgContainer = d3.selectAll('#svgContainer'); var margin = { top: 20, right: 20, bottom: 30, left: 40 }, width = 1240 - margin.left - margin.right, height = 740 / 1.5 - margin.top - margin.bottom; var x = d3.scale.linear() .range([0, width]); var y = d3.scale.linear() .range([height, 0]);
interface css .canvas { fill: #FEFFFE; } #canvasChild.canvas { fill: white; } .visible { visibility: visible; opacity: 1; } .hidden { visibility: hidden; pointer-events: none; } .textNormal { text-anchor: middle; color: steelblue; position: relative; font: 14px Calibri; } body { font: 10px sans-serif; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispEdges; } .dot { stroke: #000; } .pad956, .pad958 { opacity: 0.8; stroke: #000; } #pinDataText { text-anchor: middle; color: steelblue; position: relative; font: 14px Calibri; } .pad956Label, .pad958Label { text-anchor: middle; color: steelblue; position: relative; font: 8px Calibri; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.0.4/d3.min.js"></script> <body> <div id="title"></div> <div id="svg"></div> </body>
And alternative jsfiddle:
http://jsfiddle.net/laurieskelly/q0ubpmwj/
Both x and y use the same domain, but do not scale. This is because the height is different from the width, I know, but how to edit the y axis to use the same proportions as the x axis, but only on a smaller scale.
For example, I want x to move from 0-1.8, but y to say around, 0 - 1.2. But I want the y scale to be the same as x.
var x = d3.scale.linear() .range([0, width]); var y = d3.scale.linear() .range([height, 0]);
source share