Skip to content

Commit 9077f34

Browse files
committed
fix axis marks
1 parent 3f7bf76 commit 9077f34

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

src/lib/marks/AxisX.svelte

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,29 +201,31 @@
201201
plot,
202202
'fill'
203203
)}
204-
x={titleAlign === 'right' ? plot.width : titleAlign === 'center' ? plot.width / 2 : 0}
205-
y={5}
204+
x={plot.options.marginLeft +
205+
plot.plotWidth * (titleAlign === 'right' ? 1 : titleAlign === 'center' ? 0.5 : 0)}
206+
y={anchor === 'top' ? 13 : plot.height - 13}
206207
class="axis-x-title"
207-
dominant-baseline="hanging">{useTitle}</text>
208+
dominant-baseline={anchor === 'top' ? 'auto' : 'hanging'}>{useTitle}</text>
208209
{/if}
209210
{#if showAxis}
210211
<BaseAxisX
212+
{anchor}
213+
{className}
214+
{labelAnchor}
215+
{options}
211216
{plot}
217+
{text}
218+
{tickClass}
219+
{tickFontSize}
220+
{tickPadding}
221+
{ticks}
222+
{tickSize}
223+
height={plot.facetHeight}
224+
marginTop={plot.options.marginTop}
212225
scaleFn={plot.scales.x.fn}
213226
scaleType={plot.scales.x.type}
214227
tickFormat={useTickFormat}
215-
{ticks}
216-
marginTop={plot.options.marginTop}
217-
height={plot.facetHeight}
218-
{anchor}
219-
{tickSize}
220-
{tickPadding}
221-
{tickFontSize}
222-
{tickClass}
223-
{text}
224-
{labelAnchor}
225-
{className}
226-
{options} />
228+
title={useTitle} />
227229
{/if}
228230
</Mark>
229231

src/lib/marks/AxisY.svelte

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
data = Array.isArray(magicTicks) ? magicTicks : [],
6767
automatic = false,
6868
title,
69-
anchor,
69+
anchor = 'left',
70+
class: className,
7071
facetAnchor = 'auto',
7172
interval = typeof magicTicks === 'string' ? magicTicks : undefined,
7273
lineAnchor = 'center',
@@ -187,21 +188,23 @@
187188
{/if}
188189
{#if showAxis}
189190
<BaseAxisY
191+
{anchor}
192+
{className}
193+
{lineAnchor}
194+
{options}
190195
{plot}
196+
{text}
197+
{tickClass}
198+
{tickFontSize}
199+
{tickPadding}
200+
{ticks}
201+
{tickSize}
202+
marginLeft={plot.options.marginLeft}
191203
scaleFn={plot.scales.y.fn}
192204
scaleType={plot.scales.y.type}
193205
tickFormat={useTickFormat}
194-
{ticks}
195-
marginLeft={plot.options.marginLeft}
196-
width={plot.facetWidth}
197-
{anchor}
198-
{lineAnchor}
199-
{tickSize}
200-
{tickPadding}
201-
{tickFontSize}
202-
{tickClass}
203-
{text}
204-
{options} />
206+
title={useTitle}
207+
width={plot.facetWidth} />
205208
{/if}
206209
</Mark>
207210

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy