score:1
Accepted answer
First of all, you need to create or find some element that will be used as a hook. Next, use mousemove
to translate the axis and do a cleanup in mouseup event callback. For example:
const chart = Highcharts.chart('container', {...});
chart.customLine = chart.renderer.path([
'M',
chart.plotLeft,
chart.plotTop,
'L',
chart.plotLeft,
chart.plotTop + chart.plotHeight
]).attr({
stroke: '#ff00ff',
'stroke-width': 7
})
.on('mousedown', function() {
chart.isDraggingAxis = true;
})
.add();
chart.container.addEventListener('mousemove', function(e) {
if (chart.isDraggingAxis) {
const yAxis = chart.yAxis[0];
chart.customLine.translate(e.x - chart.plotLeft);
yAxis.labelGroup.translate(e.x - chart.plotLeft);
}
});
document.addEventListener('mouseup', function(e) {
if (chart.isDraggingAxis) {
chart.isDraggingAxis = false;
}
});
Live demo: http://jsfiddle.net/BlackLabel/jervfkoc/
API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGElement#translate
Source: stackoverflow.com
Related Query
- Highchart react - x axis draggable
- how to hide highchart x - axis data values
- How to display highchart y axis with constistant data
- same scale on x y axis in highchart
- How to dynamically change axis from linear to logarithmic in HighChart
- Overlapping Y Axis in a Multi y axis Highchart
- Highchart axis max with multiple axes
- Highchart Axis Update/ chart redraw
- Get X Axis value on bar Highchart click event
- last label in x axis with datetime format not coming in highchart
- How to place labels on opposite Y axis in Highchart without a second series
- Highchart Crosshair not touching x axis
- max Y Axis value in a Highchart
- Click event on highchart axis
- How to Add button in React Highchart Tooltip?
- Fire click event on a highchart column drilldown chart on clicking x axis for drill down reports
- How to update Highchart from inside react a component?
- Highchart axis 2 decimal places
- highchart Axis values color
- R Highchart // grouped categories in x axis
- X axis value in stackLabels Formatter in bar highchart
- How to add % symbol to Y axis values in HighChart graph?
- Swap Y Axis in Highchart
- Pan one of multiple Y axis for highchart
- Highchart Axis with only min and max series value
- change distance of x-axis labels from axis in highchart
- change distance of x-axis labels from axis in highchart
- HighCharts Draggable Plotline with Logarithmic axis scale
- Highchart heatmap: exclude the total row for color Axis
- Set series color based on X axis on a column Highchart
More Query from same tag
- highcharts ampersand
- Why any of highcharts demo example doesn't work?
- Highchart Y-axis point is not showing
- Highcharts3 change symbol color(symbolStroke) for export button on hover
- HighCharts donut - how to individually adjust height of each external segment?
- Use an array of objects for series data in Highcharts
- How to load proj4 for lat/long in highmaps using typescript and react
- Highcharts add a new data point
- *Highcharts* Drawing Percent Line Chart
- Highcharts variable threshold
- how to avail bg color for every bar in highchart
- how can i change position of inputs in high charts high-stock?
- d3 and Highcharts diagram with parent and common node
- HighCharts: Possible to summarize series data and show in title?
- Highchart gauge: How to change tick position
- Is it possible to use jQuery in wicked_pdf to render charts?
- Highcharts: overlapped columns in exported chart
- Highcharts do not render
- How to addSeries in HighChart
- Creating a marimekko chart using Highcharts
- Highcharts backgroundColor for multiple charts is only applied to one chart
- Highcharts Maps - Rounded zoom buttons
- Making Highcharts appear in a infowindow window when making an AJAX request with Google Maps
- Multiple series, multiple charts Highcharts
- How to sort order highchart pie jasperstudio by slice value min to max
- How to set reset zoom button and title to exactly center of the high charts
- How to add arrow to end of line while using type scatter
- Change Highcharts tooltip formatter from chart Object , after chart is rendered
- TCPDF not rendering dots (circles) with path variables in text file using imageSVG
- Highcharts Column chart with drilldown, remove hyperlink like formatting from x-axis labels