Created
December 4, 2017 17:14
-
-
Save dgwyer/61faacef24ea5c1c4b442b2383cecb49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example usage | |
| <XYFrame | |
| margin={ { top: 20, bottom: 80, left: 70, right: 20 } } | |
| size={[500,300]} | |
| xAccessor={ d => d[0] } | |
| yAccessor={ d => d[1] } | |
| lines={ lines } | |
| lineStyle={d => ({ | |
| stroke: "pink", | |
| strokeWidth: 2 | |
| })} | |
| showLinePoints={ true } | |
| pointStyle={{ r: 4, fill: "hotpink", stroke: "white", strokeWidth: 0 }} | |
| //legend = {true} | |
| axes={[ | |
| { orient: "left", mainAxisLine: true, tickSize: -5 }, | |
| { orient: "bottom", mainAxisLine: true, tickSize: -5, label: { | |
| name: "Standard X, Y axes with main axis lines", | |
| position: { anchor: "middle" }, // start|middle|end | |
| anchor: "end", | |
| locationDistance: 50 | |
| } }, | |
| ]} | |
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Added these two methods to axis.js | |
| const mainAxisLineGenerator = ({ xExtent, yExtent, xScale, yScale, orient }) => { | |
| let path = ""; | |
| switch (orient) { | |
| case "top": | |
| path = `M${xScale(xExtent[0])}, ${yScale(yExtent[1])}L${xScale(xExtent[1])}, ${yScale(yExtent[1])}`; | |
| break; | |
| case "bottom": | |
| path = `M${xScale(xExtent[0])}, ${yScale(yExtent[0])}L${xScale(xExtent[1])}, ${yScale(yExtent[0])}`; | |
| break; | |
| case "right": | |
| path = `M${xScale(xExtent[1])}, ${yScale(yExtent[0])}L${xScale(xExtent[1])}, ${yScale(yExtent[1])}`; | |
| break; | |
| //left | |
| default: | |
| path = `M${xScale(xExtent[0])}, ${yScale(yExtent[0])}L${xScale(xExtent[0])}, ${yScale(yExtent[1])}`; | |
| break; | |
| } | |
| return ( | |
| <Mark | |
| markType="path" | |
| stroke="black" | |
| strokeWidth="1px" | |
| simpleInterpolate={true} | |
| d={path} | |
| className={`main-axis-line ${orient}`} | |
| /> | |
| )}; | |
| export const mainAxisLine = ({ mainAxisLine = false, xExtent, yExtent, xScale, yScale, orient }) => { | |
| { | |
| if(mainAxisLine) { | |
| return mainAxisLineGenerator({ xExtent, yExtent, xScale, yScale, orient }); | |
| } | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Import the new method | |
| import { axisPieces, axisLines, mainAxisLine } from "./visualizationLayerBehavior/axis"; | |
| // ... | |
| // Update axisTickLines() at approx. line 298 | |
| const axisTickLines = ( | |
| <g key={`axes-tick-lines-${i}`} className={`axis ${d.className}`}> | |
| { axisLines({ axisParts, orient: d.orient, tickLineGenerator: d.tickLineGenerator }) } | |
| { mainAxisLine({ mainAxisLine: d.mainAxisLine, xExtent, yExtent, xScale, yScale, orient: d.orient }) } | |
| </g> | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment