highcharts 极坐标图,单独移动标签以适应小 space
highcharts polar chart, move labels individually to fit small space
我有一个极坐标图,我试图在 x 轴上移动四个标签中的两个。它是一个窄space中的菱形,所以左右标签都被切掉了。我想移动它们,但我无法让它们移动。我正在尝试将标签类别 1 和类别 3 向下移动 30 像素并向中心移动 ~100 像素。
标签代码
xAxis: {
categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4'],
tickmarkPlacement: 'on',
lineWidth: 0,
labels: {
style: { fontSize: '150%',
},
},
},
Fiddle
https://jsfiddle.net/Adam300/kuvs0eah/8/
我看过 this fiddle from here,但我无法理解它。
因为只有一个系列,我能想到的唯一解决方案是使用这个 CSS 代码:
.highcharts-xaxis-labels text:nth-child(1), .highcharts-xaxis-labels text:nth-child(3){
transform: translate(0,47px); !important;
}
虽然不完美,但很管用
您可以使用 chart.marginLeft
和 chart.marginRight
属性来定义图表容器的边距。请查看下面的代码和示例:
chart: {
polar: true,
type: 'line',
marginLeft: 100,
marginRight: 100,
style: {
fontFamily: 'Georgia',
}
}
实例:https://jsfiddle.net/fjhz4wx7/
API参考:
https://api.highcharts.com/highcharts/chart.marginLeft
https://api.highcharts.com/highcharts/chart.marginRight
亲切的问候!
我有一个极坐标图,我试图在 x 轴上移动四个标签中的两个。它是一个窄space中的菱形,所以左右标签都被切掉了。我想移动它们,但我无法让它们移动。我正在尝试将标签类别 1 和类别 3 向下移动 30 像素并向中心移动 ~100 像素。
标签代码
xAxis: {
categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4'],
tickmarkPlacement: 'on',
lineWidth: 0,
labels: {
style: { fontSize: '150%',
},
},
},
Fiddle https://jsfiddle.net/Adam300/kuvs0eah/8/
我看过 this fiddle from here,但我无法理解它。
因为只有一个系列,我能想到的唯一解决方案是使用这个 CSS 代码:
.highcharts-xaxis-labels text:nth-child(1), .highcharts-xaxis-labels text:nth-child(3){
transform: translate(0,47px); !important;
}
虽然不完美,但很管用
您可以使用 chart.marginLeft
和 chart.marginRight
属性来定义图表容器的边距。请查看下面的代码和示例:
chart: {
polar: true,
type: 'line',
marginLeft: 100,
marginRight: 100,
style: {
fontFamily: 'Georgia',
}
}
实例:https://jsfiddle.net/fjhz4wx7/
API参考:
https://api.highcharts.com/highcharts/chart.marginLeft
https://api.highcharts.com/highcharts/chart.marginRight
亲切的问候!