Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section content clipping #177

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
version: 2.1
orbs:
cypress: cypress-io/cypress@1.8.0
cypress: cypress-io/cypress@1.19.1
jobs:
unit_test:
docker:
Expand All @@ -31,12 +31,12 @@ jobs:
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn run test:unit
- run: npm run test:unit
workflows:
unit_and_integration:
jobs:
# - unit_test # running unit tests from cypress workspace to save time
- cypress/run:
yarn: true
command: yarn run test:unit && yarn run test:integration
executor: cypress/browsers-chrome78-ff70
command: npm run test:unit && npm run test:integration

683 changes: 366 additions & 317 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions site/src/gallery/contour/.metadata
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sandbox_id: c52mh
hash: 0baf0e140a1e302351f040b41c88273f65637832
sandbox_id: 0om4x
hash: 6b5199d4b5175ddf6d0bf4cd070036ffa1875cdc
12 changes: 1 addition & 11 deletions site/src/gallery/contour/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import {
Graphic,
Section,
Label,
PointLayer,
Polygon,
XAxis,
YAxis,
Title
} from '@snlab/florence/src/index.js'
import DataContainer from '@snlab/florence-datacontainer'

Expand Down Expand Up @@ -69,15 +67,7 @@
{height}
>

<!-- <Label
x={450}
y={10}
text={'Density Contours'} -->
/>

<Section
{padding}
>
<Section {padding} >
{#if done}
{#each contours as c, i}
<Polygon
Expand Down
20 changes: 13 additions & 7 deletions src/components/Core/Section/Section.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,34 @@
</script>

<defs>
<clipPath id={`clip-${sectionId}`}>
<mask id={`mask-${sectionId}-padding-bg`}>
<rect
x={Math.min(scaledCoordinates.x1, scaledCoordinates.x2)}
y={Math.min(scaledCoordinates.y1, scaledCoordinates.y2)}
width={Math.abs(scaledCoordinates.x2 - scaledCoordinates.x1)}
height={Math.abs(scaledCoordinates.y2 - scaledCoordinates.y1)} />
</clipPath>
<clipPath id={`clip-${sectionId}-data`}>
height={Math.abs(scaledCoordinates.y2 - scaledCoordinates.y1)}
fill="white" />
<rect
x={Math.min(...rangeX)}
y={Math.min(...rangeY)}
width={Math.abs(rangeX[0] - rangeX[1])}
height={Math.abs(rangeY[0] - rangeY[1])}
fill="white" />
fill="black" />
</mask>
<clipPath id={`clip-${sectionId}-data`}>
<rect
x={Math.min(...rangeX)}
y={Math.min(...rangeY)}
width={Math.abs(rangeX[0] - rangeX[1])}
height={Math.abs(rangeY[0] - rangeY[1])} />
</clipPath>
</defs>

<g class="section" clip-path={`url(#clip-${sectionId})`}>
<g class="section">
{#if paddingColor}
<rect
class="padding-background"
mask={`url(#clip-${sectionId}-data)`}
mask={`url(#mask-${sectionId}-padding-bg)`}
width="100%"
height="100%"
fill={paddingColor} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Core/Section/SectionContext/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { writable } from 'svelte/store'

class SectionContext {
constructor ({ sectionId, rangeX, rangeY, scaleX, scaleY, padding, flipX, flipY, blockReindexing }) {
this._sectionId = sectionId
this.sectionId = sectionId

this.rangeX = rangeX
this.rangeY = rangeY
Expand Down
3 changes: 3 additions & 0 deletions src/components/Core/Title/Title.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
let xRange = $sectionContext.scaleX.range()
let yRange = $sectionContext.scaleY.range()
let totalFontSize
const clipped = false

$: {
if (usePadding === true) {
Expand Down Expand Up @@ -131,6 +132,7 @@
fontFamily={titleFontFamily} fontSize={titleFontSize} fontWeight={titleFontWeight} rotation={titleRotation} anchorPoint={titleAnchorPoint}
{transition} {onClick} {onMouseover} {onMouseout}
{zoomIdentity} _asPolygon={false}
{clipped}
/>
<!-- {/if} -->

Expand All @@ -147,5 +149,6 @@
fontFamily={subtitleFontFamily} fontSize={subtitleFontSize} fontWeight={subtitleFontWeight} rotation={subtitleRotation} anchorPoint={subtitleAnchorPoint}
{transition} {onClick} {onMouseover} {onMouseout}
{zoomIdentity} _asPolygon={false}
{clipped}
/>
<!-- {/if} -->
15 changes: 8 additions & 7 deletions src/components/Guides/Axes/XAxis.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

// Contexts
const sectionContext = SectionContext.subscribe()

let xCoords
let yCoords
let tickPositions
Expand All @@ -77,6 +77,7 @@
let axisHeight
let labelAnchorPoint = 't'
let scaleX
const clipped = false

$: {
scaleX = (typeof scale === 'undefined') ? $sectionContext.scaleX : scale;
Expand Down Expand Up @@ -105,29 +106,29 @@
{#if baseLine}
<Line
x={xCoords} y={yCoords} strokeWidth={baseLineWidth} opacity={baseLineOpacity} stroke={baseLineColor}
{zoomIdentity}
{zoomIdentity} {clipped}
/>
{/if}

{#if ticks}
<LineLayer
<LineLayer
x={tickXCoords} y={tickYCoords} strokeWidth={tickWidth} opacity={tickOpacity} stroke={tickColor}
{transition} {zoomIdentity}
{transition} {zoomIdentity} {clipped}
/>
<LabelLayer
x={tickLabelXCoords} y={tickLabelYCoords} text={tickLabelText} anchorPoint={labelAnchorPoint}
rotation={labelRotate} fontFamily={labelFont} fontSize={labelFontSize}
fontWeight={labelFontWeight} opacity={labelOpacity} fill={labelColor}
{transition} {zoomIdentity}
{transition} {zoomIdentity} {clipped}
/>
{/if}

{#if title.length > 0}
<Label
<Label
x={titleXCoord} y={titleYCoord} text={title} anchorPoint={titleAnchorPoint}
rotation={titleRotation} fontFamily={titleFont} fontSize={titleFontSize}
fontWeight={titleFontWeight} opacity={titleOpacity} fill={titleColor}
{zoomIdentity}
{zoomIdentity} {clipped}
/>
{/if}

Expand Down
15 changes: 8 additions & 7 deletions src/components/Guides/Axes/YAxis.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
let axisWidth
let labelAnchorPoint = 'r'
let scaleY
const clipped = false

$: {
scaleY = (typeof scale === 'undefined') ? $sectionContext.scaleY : scale;
Expand All @@ -103,31 +104,31 @@
<g class="y-axis">

{#if baseLine}
<Line
<Line
x={xCoords} y={yCoords} strokeWidth={baseLineWidth} opacity={baseLineOpacity} stroke={baseLineColor}
{zoomIdentity}
{zoomIdentity} {clipped}
/>
{/if}

{#if ticks}
<LineLayer
<LineLayer
x={tickXCoords} y={tickYCoords} strokeWidth={tickWidth} opacity={tickOpacity} stroke={tickColor}
{transition} {zoomIdentity}
{transition} {zoomIdentity} {clipped}
/>
<LabelLayer
x={tickLabelXCoords} y={tickLabelYCoords} text={tickLabelText} anchorPoint={labelAnchorPoint}
rotation={labelRotate} fontFamily={labelFont} fontSize={labelFontSize}
fontWeight={labelFontWeight} opacity={labelOpacity} fill={labelColor}
{transition} {zoomIdentity}
{transition} {zoomIdentity} {clipped}
/>
{/if}

{#if title.length > 0}
<Label
<Label
x={titleXCoord} y={titleYCoord} text={title} anchorPoint={titleAnchorPoint}
rotation={titleRotation} fontFamily={titleFont} fontSize={titleFontSize}
fontWeight={titleFontWeight} opacity={titleOpacity} fill={titleColor}
{zoomIdentity}
{zoomIdentity} {clipped}
/>
{/if}

Expand Down
6 changes: 5 additions & 1 deletion src/components/Guides/Legends/DiscreteLegend.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
let rangeCoordsY
let xRange = $sectionContext.scaleX.range()
let yRange = $sectionContext.scaleY.range()
const clipped = false

let colorXStartCoords
let colorXEndCoords
Expand Down Expand Up @@ -362,6 +363,7 @@
{stroke}
{strokeWidth}
{zoomIdentity}
{clipped}
/>

<LabelLayer
Expand All @@ -377,10 +379,11 @@
fill={labelColor}
{transition}
{zoomIdentity}
{clipped}
/>

{#if title.length > 0}
<Label
<Label
x={ () => { return titleX } }
y={ () => { return titleY } }
text={title}
Expand All @@ -393,6 +396,7 @@
fill={titleColor}
{transition}
{zoomIdentity}
{clipped}
/>
{/if}
</g>
4 changes: 4 additions & 0 deletions src/components/Guides/Legends/GradientLegend.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
let rangeCoordsY
let xRange = $sectionContext.scaleX.range()
let yRange = $sectionContext.scaleY.range()
const clipped = false

let colorGeoms
let offsets
Expand Down Expand Up @@ -389,6 +390,7 @@
{stroke}
{strokeWidth}
{zoomIdentity}
{clipped}
/>

<LabelLayer
Expand All @@ -404,6 +406,7 @@
fill={labelColor}
{transition}
{zoomIdentity}
{clipped}
/>
{#if title.length > 0}
<Label
Expand All @@ -419,6 +422,7 @@
fill={titleColor}
{transition}
{zoomIdentity}
{clipped}
/>
{/if}
</g>
3 changes: 2 additions & 1 deletion src/components/Marks/FuncLine/FuncLine.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
// Other
export let zoomIdentity = undefined
export let blockReindexing = false
export let clipped = true

// Contexts
const graphicContext = GraphicContext.subscribe()
Expand Down Expand Up @@ -213,7 +214,7 @@

{#if $graphicContext.output() === 'svg'}

<path
<path clip-path={clipped ? `url(#clip-${$sectionContext.sectionId}-data)` : 'none'}
class="line"
d={generatePath($tr_screenGeometry)}
fill="none"
Expand Down
2 changes: 2 additions & 0 deletions src/components/Marks/Label/Label.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
// Other
export let zoomIdentity = undefined
export let blockReindexing = false
export let clipped = true
</script>

<Mark
Expand All @@ -59,4 +60,5 @@
{onTouchdown} {onTouchup} {onTouchover} {onTouchout} {onTouchdrag}
{onSelect} {onDeselect}
{zoomIdentity} _asPolygon={false} {blockReindexing}
{clipped}
/>
2 changes: 2 additions & 0 deletions src/components/Marks/Label/LabelLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
export let key = undefined
export let zoomIdentity = undefined
export let blockReindexing = false
export let clipped = true
</script>

<Layer
Expand All @@ -60,4 +61,5 @@
{onTouchdown} {onTouchup} {onTouchover} {onTouchout} {onTouchdrag}
{onSelect} {onDeselect}
{key} {zoomIdentity} _asPolygon={false} {blockReindexing}
{clipped}
/>
2 changes: 2 additions & 0 deletions src/components/Marks/Line/Line.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
export let interpolate = true
export let zoomIdentity = undefined
export let blockReindexing = false
export let clipped = true
</script>

<Mark
Expand All @@ -48,4 +49,5 @@
{onTouchdown} {onTouchup} {onTouchover} {onTouchout} {onTouchdrag}
{onSelect} {onDeselect}
{interpolate} {zoomIdentity} _asPolygon={false} {blockReindexing}
{clipped}
/>
2 changes: 2 additions & 0 deletions src/components/Marks/Line/LineLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
export let interpolate = true
export let zoomIdentity = undefined
export let blockReindexing = false
export let clipped = true
</script>

<Layer
Expand All @@ -49,4 +50,5 @@
{onTouchdown} {onTouchup} {onTouchover} {onTouchout} {onTouchdrag}
{onSelect} {onDeselect}
{interpolate} {zoomIdentity} {key} _asPolygon={false} {blockReindexing}
{clipped}
/>
Loading