Skip to content

Commit caae335

Browse files
committed
Fix Ordinal foregroungGraphics rendering
1 parent 438845d commit caae335

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

src/components/OrdinalFrame.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,11 @@ class OrdinalFrame extends React.Component<OrdinalFrameProps, State> {
16401640
}
16411641
}
16421642

1643+
const renderedForegroundGraphics =
1644+
typeof foregroundGraphics === "function"
1645+
? foregroundGraphics({ size, margin })
1646+
: foregroundGraphics
1647+
16431648
return (
16441649
<Frame
16451650
name="ordinalframe"
@@ -1682,7 +1687,7 @@ class OrdinalFrame extends React.Component<OrdinalFrameProps, State> {
16821687
margin={margin}
16831688
columns={projectedColumns}
16841689
backgroundGraphics={backgroundGraphics}
1685-
foregroundGraphics={[foregroundGraphics, oLabels]}
1690+
foregroundGraphics={[renderedForegroundGraphics, oLabels]}
16861691
beforeElements={beforeElements}
16871692
afterElements={afterElements}
16881693
downloadButton={downloadButton}

src/docs/components/CanvasInteractionRaw.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default class DecisionMatrixExample extends React.Component {
2929
fetch(`${ROOT}/sampledata/diamonds.csv`)
3030
.then(response => response.text())
3131
.then(data => {
32-
// console.log(data)
3332
const parsedDiamonds = []
3433
csvParse(data).forEach(d => {
3534
parsedDiamonds.push({

src/docs/components/CreatingBarChart.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,33 @@ export default class CreatingBarChart extends React.Component {
177177
axis={{ orient: "left", label: "Favorites + Retweets" }}
178178
margin={{ left: 70, bottom: 50, right: 5, top: 55 }}
179179
oPadding={15}
180+
backgroundGraphics={({ size, margin }) => (
181+
<g>
182+
<rect
183+
fill="#fffceb"
184+
stroke="#f8ffeb"
185+
width={size[0] - margin.right - margin.left}
186+
height={size[1] - margin.top - margin.bottom}
187+
x={margin.left}
188+
y={margin.top}
189+
strokeWidth={1}
190+
/>
191+
<text>{JSON.stringify(margin)}</text>
192+
</g>
193+
)}
194+
foregroundGraphics={({ size, margin }) => (
195+
<g>
196+
<line
197+
strokeWidth={3}
198+
stroke={"#fcebff"}
199+
x1={margin.left}
200+
x2={size[0] - margin.right}
201+
y1={size[1] - margin.bottom}
202+
y2={size[1] - margin.bottom}
203+
/>
204+
</g>
205+
)}
206+
/>
180207
/>
181208
</div>
182209
),

src/docs/components/CreatingLineChart.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,31 @@ export default class CreatingLineChart extends React.Component {
489489
customDoubleClickBehavior={d =>
490490
console.info("customDoubleClickBehavior d", d)
491491
}
492+
backgroundGraphics={({ size, margin }) => (
493+
<g>
494+
<rect
495+
fill="#fffceb"
496+
stroke="#f8ffeb"
497+
width={size[0] - margin.right}
498+
height={size[1] - margin.top - margin.bottom}
499+
x={margin.left}
500+
y={margin.top}
501+
/>
502+
<text>{JSON.stringify(margin)}</text>
503+
</g>
504+
)}
505+
foregroundGraphics={({ size, margin }) => (
506+
<g>
507+
<line
508+
strokeWidth={3}
509+
stroke={"#fcebff"}
510+
x1={margin.left}
511+
x2={size[0] - margin.right}
512+
y1={size[1] - margin.bottom}
513+
y2={size[1] - margin.bottom}
514+
/>
515+
</g>
516+
)}
492517
/>
493518
<h3>Flat Data</h3>
494519
<ResponsiveXYFrame

0 commit comments

Comments
 (0)