score:2
You cannot do this via css because there is no line-height
presentational attribute support in svg. See the answer svg-how-to-set-text-line-height. What Highcharts do - it mocks html-css line-height
property on svg by setting dy property. In SVG dy is not a presentational attribute so it cannot be set in stylesheet.
To preserve the lineheight option, you can modify Highcharts internal method so its cssish style will be applied.
var H = Highcharts;
H.wrap(H.Tick.prototype, 'addLabel', function (p) {
p.call(this);
const label = this.label;
const labelOptions = this.axis.options.labels;
if (label) {
label.css({
lineHeight: labelOptions.style.lineHeight
})
}
})
Axis config:
labels: {
style: {
textOverflow: 'none',
lineHeight: 12
}
},
Live example and output:
https://jsfiddle.net/4dztcw5d/
As I mentioned in the comment, you can also set labels.useHTML to true, build a proper html and apply to it html-css styling, including line-height.
score:0
For some reason the highcharts library that you are using doesn't take into account some of the css. I tried using this one http://code.highcharts.com/highcharts.js and seems to work i added in the x-axis label style
fontSize:'15px',
lineHeight: "12"
and had to set the colors with !important
text:nth-child(odd){ fill: blue!important; }
text:nth-child(even){ fill: red!important; }
and it seems to work, here is the codepen http://codepen.io/anon/pen/ryWoxo
Source: stackoverflow.com
Related Query
- How to adjust line-height/ellipses in Highcharts axis labels
- Highcharts - how to set line height in multiline annotations labels in styled mode
- How can I force ticks/grid lines on a Highcharts datetime X axis to arbitrarily line up with data points?
- How to position labels for plotbands on y axis in Highcharts
- How To Show All Data Labels For Datetime Axis In Highcharts
- How to stop Highcharts y-Axis bar-chart labels being skipped when height is small?
- How to handle mouse events on axis labels in highcharts
- Highcharts - How to plot a X axis line on my bell curve (Standard Deviation Curve)
- Highcharts - How to force line chart to be visible above X Axis
- How do I plot the x axis line using Highcharts when pegged at 0?
- How to add text labels to a numerical x axis in Highcharts
- How to adjust vertical labels on this Line Chart?
- How to add labels to the end of a highcharts line graph
- How to display months in x axis labels in highcharts
- How to show labels selectively in certain points in Line chart of HighCharts
- Highcharts | Line height control for plot band labels in styled mode
- How to get height of axis column's ticks in highcharts
- HighCharts. How to display X axis labels line without data?
- Highcharts : How do i align data labels above the axis in column chart?
- How to hide line but keep data labels in highcharts
- HighCharts - Angular, how to get y axis labels on the vertical lines drawn from x axis
- How to get points information when hovering over axis labels in highcharts using custom-events library?
- How to fix formatting of axis labels in Highcharts when surrounding the contents with div?
- HighCharts donut - how to individually adjust height of each external segment?
- how to draw end line on x axis in highcharts
- How to hardcode arbitrary Tick text labels on y axis in highcharts
- how to set the interval of points on Y - Axis highcharts
- How to hide labels in the highcharts in the pie
- How replicate the value of Y Axis on both sides of the axis in Highcharts
- How to prevent highcharts from shortening labels with ellipsis
More Query from same tag
- No results in Highcharts with loading from JSON
- Highcharts Angular - How to show group size in tooltip
- Highchart - Dual Axes Line chart issue
- highchart dynamic binding using asp.net
- Why does Highstock initialisation set series variable to null?
- Highcharts how to use JavaScript variable as series data source?
- Jasper charts - Undefined length exception
- Hide inactive dates from datetime X-Axis
- Add gridline on dynamic marker highchart
- How to display custom or non-series data array on Highcharts tooltip on hover?
- Highcharts tooltip looks weird
- Overriding log2lin and lin2log for Highcharts does not appear to work
- continue the line drawing on dotnet highchart
- Change xAxis label style on data series click, Highcharts/React
- Highcharts - programmatically slice
- How to change color of bar in column chart with different level of percentage in highcharts
- Highchart with Range selector for SQL Data in html website
- How to display stack total just below the stack columns and not inside?
- Realtime monitoring node.js server
- HighCharts - Graph axis starting BEFORE first data point
- Use comma values as datapoints within a PieChart
- How to get 2 data-points with one name in series Line Graph Highcharts Reactjs
- Highcharts: enforce options when adding a serie with addSeries
- The RTL language (Arabic) is not working with HighCharts pie chart correctly, how can I fix this?
- React Highcharts 'forExport' of undefined
- Long length string is not displaying correctly in the chart
- Highcharts create chart with coloraxis object
- change the color of Highmap
- How do you create a survey that will immediately display the results as a pie chart on a website?
- HighCharts: 3D Column Chart change borderColor on select