Comments (7)
I could fix it by adding following lines to Exporting.ts#L1216:
const chartHeightFactor = chart.chartHeight / options.exporting.sourceHeight;
const chartWidthFactor = chart.chartWidth / options.exporting.sourceWidth;
options.annotations.forEach((annotation, index) => {
if (
typeof annotation.labels[0] !== 'undefined' &&
typeof chart.annotations[index]?.labels[0]?.options !== 'undefined'
) {
annotation.labels[0].x = chart.annotations[index].labels[0].options.x * chartWidthFactor;
annotation.labels[0].y = chart.annotations[index].labels[0].options.y * chartHeightFactor;
}
});
Since I don't think this is the right place in the code to fix the bug, I waited to submit a pull request.
from highcharts.
Hi @ppcmetrics-thp!
Thank you for reporting the issue!
Your suggestion seems to be valid, thank you for that!
from highcharts.
Hi @karolkolodziej , but is this really the right place to fix the bug? Isn't there an update function in the annotation module which needs to be fixed instead of the export function?
from highcharts.
@karolkolodziej When preparing the pull request I'm getting following error in VS Code:
Property 'annotations' does not exist on type 'ChartComposition'.ts(2339)
This error comes from the line:
typeof chart.annotations[index]?.labels[0]?.options !== 'undefined'
I suppose this error would fail the defined GitHub actions. Could you show me please how I can avoid this error?
Changing the line like following doesn't solve the problem:
typeof chart?.annotations[index]?.labels[0]?.options !== 'undefined'
from highcharts.
We have this thing called AnnotationChart and this should be used to properly access the type.
Altho as I think about it, putting annotation-related code into the exporting module isn't ideal. It looks like a good workaround but maybe there is a better place for the fix.
from highcharts.
Possible workarounds:
Workaround 1:
https://jsfiddle.net/BlackLabel/yazgf9xj/
Snippet:
Highcharts.Annotation.prototype.onMouseUp = function() {
const chart = this.chart,
annotation = this.target || this,
annotationsOptions = chart.options.annotations,
index = chart.annotations.indexOf(annotation);
this.removeDocEvents();
// annotationsOptions[index] = annotation.options;
}
Workaround 2:
https://jsfiddle.net/BlackLabel/yazgf9xj/2/
Highcharts.Annotation.prototype.onMouseUp = function() {
const chart = this.chart,
annotation = this.target || this,
annotationsOptions = chart.options.annotations,
index = chart.annotations.indexOf(annotation);
this.removeDocEvents();
annotation.options.labels = annotation.labels.map(label => label.options);
annotation.options.shapes = annotation.shapes.map(shape => shape.options);
annotationsOptions[index] = annotation.options;
}
from highcharts.
Thank you for the fix!
from highcharts.
Related Issues (20)
- Highcharts/Highstocks minor grid lines disappeared if there is a break HOT 2
- Plotlines are not showing up properly when tickAmount is set HOT 1
- Save chart button should also save selected Range Selector HOT 1
- incomplete changelogs HOT 1
- Inconsistent Decimal Formatting with columnTypes and decimalPoint in Data Property HOT 1
- Downloaded Chart does not render `Latex` HOT 1
- Bar chart with different series types rendered with cuts HOT 3
- Tick-length difference in Highcharts version 11.4.1 HOT 2
- "geoheatmap" series disappear after enable interpolation HOT 3
- Chart is shrinking with every re-render. HOT 1
- Add legendColor option for series
- Safari: undefined is not an object (evaluating 'AxisClass.prototype') HOT 2
- "Print chart" shows empty chart when using pattern fills HOT 1
- Column series doesn't exit boost mode when whole chart is boosted with `seriesThreshold` HOT 2
- Chart.reflow() not working for me. HOT 1
- Series are hiding when i click it on the legend HOT 2
- Some data is not displayed on xrange graph with min and max on X axis HOT 1
- Templating fails to parse sub expressions inside nested ifs
- Weird behaviour calculating minWidth dynamically HOT 2
- Option to use Canvas instead of SVG for improved performance HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from highcharts.