Skip to content
Open
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
2 changes: 2 additions & 0 deletions src/component/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface AxisTick {
coord: number
value: number | string
text: string
height?: number
width?: number
}

export interface AxisRange extends VisibleRange {
Expand Down
32 changes: 20 additions & 12 deletions src/view/GridView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ export default class GridView extends View {
const horizontalShow = horizontalStyles.show
if (horizontalShow) {
const yAxis = pane.getAxisComponent()
const attrs: LineAttrs[] = yAxis.getTicks().map(tick => ({
coordinates: [
{ x: 0, y: tick.coord },
{ x: bounding.width, y: tick.coord }
]
}))
const attrs: LineAttrs[] = yAxis.getTicks().map(tick => {
// 如果 tick 有自定义的 width,使用 tick.width,否则使用 bounding.width
const lineWidth = tick.width ?? bounding.width
return {
coordinates: [
{ x: 0, y: tick.coord },
{ x: lineWidth, y: tick.coord }
]
}
})
this.createFigure({
name: 'line',
attrs,
Expand All @@ -49,12 +53,16 @@ export default class GridView extends View {
const verticalShow = verticalStyles.show
if (verticalShow) {
const xAxis = chart.getXAxisPane().getAxisComponent()
const attrs: LineAttrs[] = xAxis.getTicks().map(tick => ({
coordinates: [
{ x: tick.coord, y: 0 },
{ x: tick.coord, y: bounding.height }
]
}))
const attrs: LineAttrs[] = xAxis.getTicks().map(tick => {
// 如果 tick 有自定义的 height,使用 tick.height,否则使用 bounding.height
const lineHeight = tick.height ?? bounding.height
return {
coordinates: [
{ x: tick.coord, y: 0 },
{ x: tick.coord, y: lineHeight }
]
}
})
this.createFigure({
name: 'line',
attrs,
Expand Down