pageX, pageY to chartX, chartY's datapoints not coord highcharts












-1















Is there a way to convert the coordinates of the entire page's X and Y coordinates to the chart's point?



I know you can get it in reverse.



var manualPt = {pageX:155, pageY: 242} //<--the point I want to display
//on the chart as a datapoint and not a chartX, chartY coordinate.

function onClick(e) {
$('#report').text('x: ' + e.pageX+ ', y: ' + e.pageY).css({
'position': 'absolute',
'left': e.offsetX,
'top': e.offsetY
})
//this would be the reverse.. knowing where the point on the chart is
//and then get pageX and pageY
}

var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {},
tooltip: {
enabled: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
events: {
click: onClick
}

}]
});


http://jsfiddle.net/pinktoadette/yd6vrg4o/



How can I accomplish this? Also it is possible that the coords of pageX and pageY may not be a data series in the existing chart.










share|improve this question























  • The entire page (also outside the chart?) or just the chart div, like this: jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/…?

    – ewolden
    Nov 20 '18 at 15:03











  • outside of the chart. So the provided pageX and pageY is retrieved from a parent. I'm trying to pass this parent coord to child, within child is highcharts.

    – jaimers
    Nov 20 '18 at 15:18











  • How do you imagine such a point is plotted? Since it is outside of the bounds of highcharts, what should that point look like? I think that you would need to create your own function that translates the pageX and pageY into coordinates, based on the windowsize.

    – ewolden
    Nov 20 '18 at 15:20











  • it'll be a point, assuming it's within the highcharts element. how do i transfer the pageX to the chart's data, that is my question..

    – jaimers
    Nov 20 '18 at 16:11
















-1















Is there a way to convert the coordinates of the entire page's X and Y coordinates to the chart's point?



I know you can get it in reverse.



var manualPt = {pageX:155, pageY: 242} //<--the point I want to display
//on the chart as a datapoint and not a chartX, chartY coordinate.

function onClick(e) {
$('#report').text('x: ' + e.pageX+ ', y: ' + e.pageY).css({
'position': 'absolute',
'left': e.offsetX,
'top': e.offsetY
})
//this would be the reverse.. knowing where the point on the chart is
//and then get pageX and pageY
}

var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {},
tooltip: {
enabled: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
events: {
click: onClick
}

}]
});


http://jsfiddle.net/pinktoadette/yd6vrg4o/



How can I accomplish this? Also it is possible that the coords of pageX and pageY may not be a data series in the existing chart.










share|improve this question























  • The entire page (also outside the chart?) or just the chart div, like this: jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/…?

    – ewolden
    Nov 20 '18 at 15:03











  • outside of the chart. So the provided pageX and pageY is retrieved from a parent. I'm trying to pass this parent coord to child, within child is highcharts.

    – jaimers
    Nov 20 '18 at 15:18











  • How do you imagine such a point is plotted? Since it is outside of the bounds of highcharts, what should that point look like? I think that you would need to create your own function that translates the pageX and pageY into coordinates, based on the windowsize.

    – ewolden
    Nov 20 '18 at 15:20











  • it'll be a point, assuming it's within the highcharts element. how do i transfer the pageX to the chart's data, that is my question..

    – jaimers
    Nov 20 '18 at 16:11














-1












-1








-1








Is there a way to convert the coordinates of the entire page's X and Y coordinates to the chart's point?



I know you can get it in reverse.



var manualPt = {pageX:155, pageY: 242} //<--the point I want to display
//on the chart as a datapoint and not a chartX, chartY coordinate.

function onClick(e) {
$('#report').text('x: ' + e.pageX+ ', y: ' + e.pageY).css({
'position': 'absolute',
'left': e.offsetX,
'top': e.offsetY
})
//this would be the reverse.. knowing where the point on the chart is
//and then get pageX and pageY
}

var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {},
tooltip: {
enabled: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
events: {
click: onClick
}

}]
});


http://jsfiddle.net/pinktoadette/yd6vrg4o/



How can I accomplish this? Also it is possible that the coords of pageX and pageY may not be a data series in the existing chart.










share|improve this question














Is there a way to convert the coordinates of the entire page's X and Y coordinates to the chart's point?



I know you can get it in reverse.



var manualPt = {pageX:155, pageY: 242} //<--the point I want to display
//on the chart as a datapoint and not a chartX, chartY coordinate.

function onClick(e) {
$('#report').text('x: ' + e.pageX+ ', y: ' + e.pageY).css({
'position': 'absolute',
'left': e.offsetX,
'top': e.offsetY
})
//this would be the reverse.. knowing where the point on the chart is
//and then get pageX and pageY
}

var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {},
tooltip: {
enabled: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
events: {
click: onClick
}

}]
});


http://jsfiddle.net/pinktoadette/yd6vrg4o/



How can I accomplish this? Also it is possible that the coords of pageX and pageY may not be a data series in the existing chart.







highcharts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 14:37









jaimersjaimers

6091130




6091130













  • The entire page (also outside the chart?) or just the chart div, like this: jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/…?

    – ewolden
    Nov 20 '18 at 15:03











  • outside of the chart. So the provided pageX and pageY is retrieved from a parent. I'm trying to pass this parent coord to child, within child is highcharts.

    – jaimers
    Nov 20 '18 at 15:18











  • How do you imagine such a point is plotted? Since it is outside of the bounds of highcharts, what should that point look like? I think that you would need to create your own function that translates the pageX and pageY into coordinates, based on the windowsize.

    – ewolden
    Nov 20 '18 at 15:20











  • it'll be a point, assuming it's within the highcharts element. how do i transfer the pageX to the chart's data, that is my question..

    – jaimers
    Nov 20 '18 at 16:11



















  • The entire page (also outside the chart?) or just the chart div, like this: jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/…?

    – ewolden
    Nov 20 '18 at 15:03











  • outside of the chart. So the provided pageX and pageY is retrieved from a parent. I'm trying to pass this parent coord to child, within child is highcharts.

    – jaimers
    Nov 20 '18 at 15:18











  • How do you imagine such a point is plotted? Since it is outside of the bounds of highcharts, what should that point look like? I think that you would need to create your own function that translates the pageX and pageY into coordinates, based on the windowsize.

    – ewolden
    Nov 20 '18 at 15:20











  • it'll be a point, assuming it's within the highcharts element. how do i transfer the pageX to the chart's data, that is my question..

    – jaimers
    Nov 20 '18 at 16:11

















The entire page (also outside the chart?) or just the chart div, like this: jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/…?

– ewolden
Nov 20 '18 at 15:03





The entire page (also outside the chart?) or just the chart div, like this: jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/…?

– ewolden
Nov 20 '18 at 15:03













outside of the chart. So the provided pageX and pageY is retrieved from a parent. I'm trying to pass this parent coord to child, within child is highcharts.

– jaimers
Nov 20 '18 at 15:18





outside of the chart. So the provided pageX and pageY is retrieved from a parent. I'm trying to pass this parent coord to child, within child is highcharts.

– jaimers
Nov 20 '18 at 15:18













How do you imagine such a point is plotted? Since it is outside of the bounds of highcharts, what should that point look like? I think that you would need to create your own function that translates the pageX and pageY into coordinates, based on the windowsize.

– ewolden
Nov 20 '18 at 15:20





How do you imagine such a point is plotted? Since it is outside of the bounds of highcharts, what should that point look like? I think that you would need to create your own function that translates the pageX and pageY into coordinates, based on the windowsize.

– ewolden
Nov 20 '18 at 15:20













it'll be a point, assuming it's within the highcharts element. how do i transfer the pageX to the chart's data, that is my question..

– jaimers
Nov 20 '18 at 16:11





it'll be a point, assuming it's within the highcharts element. how do i transfer the pageX to the chart's data, that is my question..

– jaimers
Nov 20 '18 at 16:11












1 Answer
1






active

oldest

votes


















0














You can calculate the pixel position of the point relative to the chart and use axis toValue method to get real data:



chart: {
renderTo: 'container',
events: {
load() {
var chart = this,
xAxis = chart.xAxis[0],
yAxis = chart.yAxis[0],
container = chart.renderTo,
x = xAxis.toValue(manualPt.pageX - container.offsetLeft),
y = yAxis.toValue(manualPt.pageY - container.offsetTop);

this.series[1].addPoint({
x: x,
y: y
});
}
}
}


API: https://api.highcharts.com/class-reference/Highcharts.Axis#toValue



Live demo: http://jsfiddle.net/BlackLabel/5pytc8mb/






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395385%2fpagex-pagey-to-chartx-chartys-datapoints-not-coord-highcharts%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can calculate the pixel position of the point relative to the chart and use axis toValue method to get real data:



    chart: {
    renderTo: 'container',
    events: {
    load() {
    var chart = this,
    xAxis = chart.xAxis[0],
    yAxis = chart.yAxis[0],
    container = chart.renderTo,
    x = xAxis.toValue(manualPt.pageX - container.offsetLeft),
    y = yAxis.toValue(manualPt.pageY - container.offsetTop);

    this.series[1].addPoint({
    x: x,
    y: y
    });
    }
    }
    }


    API: https://api.highcharts.com/class-reference/Highcharts.Axis#toValue



    Live demo: http://jsfiddle.net/BlackLabel/5pytc8mb/






    share|improve this answer




























      0














      You can calculate the pixel position of the point relative to the chart and use axis toValue method to get real data:



      chart: {
      renderTo: 'container',
      events: {
      load() {
      var chart = this,
      xAxis = chart.xAxis[0],
      yAxis = chart.yAxis[0],
      container = chart.renderTo,
      x = xAxis.toValue(manualPt.pageX - container.offsetLeft),
      y = yAxis.toValue(manualPt.pageY - container.offsetTop);

      this.series[1].addPoint({
      x: x,
      y: y
      });
      }
      }
      }


      API: https://api.highcharts.com/class-reference/Highcharts.Axis#toValue



      Live demo: http://jsfiddle.net/BlackLabel/5pytc8mb/






      share|improve this answer


























        0












        0








        0







        You can calculate the pixel position of the point relative to the chart and use axis toValue method to get real data:



        chart: {
        renderTo: 'container',
        events: {
        load() {
        var chart = this,
        xAxis = chart.xAxis[0],
        yAxis = chart.yAxis[0],
        container = chart.renderTo,
        x = xAxis.toValue(manualPt.pageX - container.offsetLeft),
        y = yAxis.toValue(manualPt.pageY - container.offsetTop);

        this.series[1].addPoint({
        x: x,
        y: y
        });
        }
        }
        }


        API: https://api.highcharts.com/class-reference/Highcharts.Axis#toValue



        Live demo: http://jsfiddle.net/BlackLabel/5pytc8mb/






        share|improve this answer













        You can calculate the pixel position of the point relative to the chart and use axis toValue method to get real data:



        chart: {
        renderTo: 'container',
        events: {
        load() {
        var chart = this,
        xAxis = chart.xAxis[0],
        yAxis = chart.yAxis[0],
        container = chart.renderTo,
        x = xAxis.toValue(manualPt.pageX - container.offsetLeft),
        y = yAxis.toValue(manualPt.pageY - container.offsetTop);

        this.series[1].addPoint({
        x: x,
        y: y
        });
        }
        }
        }


        API: https://api.highcharts.com/class-reference/Highcharts.Axis#toValue



        Live demo: http://jsfiddle.net/BlackLabel/5pytc8mb/







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 14:30









        ppotaczekppotaczek

        5,6211210




        5,6211210
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395385%2fpagex-pagey-to-chartx-chartys-datapoints-not-coord-highcharts%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?