Okay
  Public Ticket #2870567
Using callbacks
Closed

Comments

  • Kevin Noll started the conversation

    I am trying to use wpdatachartscallbacks to add an annotation to a highcharts bar chart. I am able to successfully add a line and annotation, but when I do, all the settings that were entered into the chart create wizard seem to be lost. For example, the Y axis label is just "Values" and not the label that I entered into the wizard. If I disable the call back, then the settings are all as expected.

    I tried printing the chart object to the JS console at the function entrance and just before function exit. The the y-axis label is "values" at function entrance and exit.

    Please advise on how to have the settings from the wizard combined with the modifications being made in the callback.

    My example code is below:

    <script type="text/javascript">
    jQuery(window).on('load',function(){ 
        if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; } 
        wpDataChartsCallbacks[7] = function(obj){ 
            console.log("PRINTING OBJ");
            console.log(obj);
            obj.options.annotations = [{
              draggable: '',
              labelOptions: {
              shape: 'connector',
              align: 'right',
              justify: false,
              crop: true,
              style: {
                fontSize: '0.8em',
                textOutline: '1px white'
                }
              },
              labels: [
                {
                text: 'My text',
                point: {
                  x: 'Point A',
                  y: 25
                  }
                }
              ]
            }
            ]
            
            obj.options.yAxis = {
              plotLines: [{
                color: '#FF0000',
                width: 2,
                value: 25,
                }]
              }
    console.log(obj);

        }
    });
    </script>

  •  2,507
    Aleksandar replied

    Hello Kevin

    Please note that using hooks or wpDataTable and wpDataChart callbacks requires a certain level of programming skills and included support refers only to advice.

    We can't say for sure what's causing the issue just by looking at the callback, so getting to the bottom of this behavior would take a lot of time debugging and testing the code. As this is not included in the provided support for the plugin, our developers are unable to help you with this any further.

    I can take a look, but I can't promise anything.

    Please provide me a temporary WP-admin (administrator) user for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. 

    We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course, we do not provide login data to third parties. 

    You can write credentials here just check PRIVATE Reply so nobody can see them except us.

    Also, make sure to share the page where the callback is applied with me, and let me know where I can find the callback.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Kevin Noll replied

    Thank you for the response. Unfortunately my development site is behind a firewall and inaccessible to the Internet.

    I was able to make some progress and would like you to confirm a technical behavior for wpDataCharts.

    The documentation for wpDataChartsCallbacks implies that the callback has access to all of the classes and methods found in the charting library (Highcharts for me). However, it appears that the callbacks are executed before the chart object is created. If that is correct, then the callback does not have access to the Highchart object, but only has access to the configuration object that gets passed into Highchart when the chart is rendered.

    Could you confirm this behavior?


  • Kevin Noll replied

    After further studying the Highcharts API and digging further into the wpDataTables code, it appears that my annotations are not working because the Highcharts annotations.js is not being included by wpDataTables.

    Per the Highcharts documentation, annotations are enabled by including

    https://code.highcharts.com/modules/annotations.js

    Could you tell me a way to have wpDataTables include this without me editing the plugin code?

  •  2,507
    Aleksandar replied

    Hello Kevin.

    Before the HIghcharts object is created, the options from our plugin are being forwarded, and if you're using callbacks, then the options from the plugin can be overridden before they are forwarded to the creation of the Highcharts object.

    I'll have to reach out to our developers about your annotation question as I'm not sure about that. I'll get back to you as soon as I hear from them.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2,507
    Aleksandar replied

    Hey Kevin

    Our developers said that they haven't received similar requests in the past, so this was never added. You would need to add it to the code of the plugin if you want to use it.

    I'll ask you to, please, add this as a feature suggestion on this page, and our developers will add it in one of our future updates.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables