Giter Club home page Giter Club logo

Comments (5)

maertz avatar maertz commented on July 28, 2024

Hi SD,

It's not necessary to call the capture method again, If you already entered the annotation mode, just if you wish to replace it's context. Therefore you just need to call the "toJPG" method directly like following:

// SAVE TO JPG
chart["export"].toJPG( {}, function( base64 ) {

  // LOG IMAGE DATA
  console.log( base64 );

  // CREATE LINK TO OPEN BASE64 IMAGE IN NEW TAB
  var a = document.createElement( "a" );
  a.setAttribute( "href", base64 );
  a.setAttribute( "target", "_blank" );
  a.setAttribute( "style", "display: block; margin-top: 150px;" );
  a.innerHTML = "Open embedded base64-image";

  var div = document.createElement( "div" );
  div.setAttribute( "style", "position: absolute; width: 100%; top:0; bottom: 0; background-color: rgba(255,255,255,.9); z-index: 1337; display: block;text-align: center;" );
  div.appendChild( a );

  this.setup.chart.div.appendChild( div );
} );

In addition following flag indicates if the chart is currently in annotation mode or not:

chart.export.drawing.buffer.enabled

from export.

debsush avatar debsush commented on July 28, 2024

Hi,

Your method worked. I changed chart["export"].toJPG to this.toJPG to make it work. However, I am unable to make use of the flag

When I try console.log(chart.export.drawing.buffer.enabled); just to check the result when in Annotation Mode, I get the following error
Uncaught ReferenceError: chart is not defined
When I try console.log(this.chart.export.drawing.buffer.enabled);
Cannot read property 'export' of undefined
When I try console.log(this.export.drawing.buffer.enabled);
Uncaught TypeError: Cannot read property 'drawing' of undefined

Please suggest since I would like to use the below logic

if (chart.export.drawing.buffer.enabled == TRUE) {
logic1;
} else {
logic2;
}

from export.

maertz avatar maertz commented on July 28, 2024

Please ensure your chart has been initiated / created and the export is ready to be able to check this flag. Following function does that, you just need to pass the instance you want to check:

    function chartInAnnotationMode( chart ) {
        var plugin = chart["export"] || {
            drawing: {
                buffer: {
                    enabled: false
                }
            }
        };
        var inAnnotationMode = plugin.drawing.buffer.enabled ? true : false;

        return chart.chartCreated && inAnnotationMode;
    }

from export.

kthangabalu avatar kthangabalu commented on July 28, 2024

Hi ,
I couldn't reset the annotations mode.
if (chart.export.drawing.buffer.enabled === true) {
}
I am using the above condition to check whether the chart is in annotations. once the annotated chart is exported , i just want to reset the annotations mode. Could somebody please let me know how to do that?

from export.

martynasma avatar martynasma commented on July 28, 2024

Try this:

chart["export"].drawing.handler.done();

from export.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.