Okay
  Public Ticket #2345879
Issues with Plotting Time Series
Closed

Comments

  • Baran Kaypakoglu started the conversation

    I have a time series data on my x axis, which is only years. When importing my dataset I choose data, and type as year at the very bottom. However, when the import is complete my dataset resets to day format such as DD/MM/YYYY. I only want year. How is this possible ??

  •  2,572
    Aleksandar replied

    Hello Baran

    Chart engines do not inherit any formats you set up in wpDataTables (date, time or number), and there are no built-in options to change the format in the chart, but you can use wpdatachart callbacks.

    For example, this example in our FAQ section shows how to change the number format using the callback. The table, however, looks like this:

    7576823489.png

    And Year is saved as Integer, not Date. Perhaps this will help you out more than working with callbacks, to change the chart's date format.

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

    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

  • Baran Kaypakoglu replied

    Hi Aleksandar,

    That is exactly what I did, saving the year as integer. I guess there is no other way to show only the year by using the date formats. But, understood. We need to fiddle with some Javascript to shape the charts into  exactly how we want'em. My expectation was that it was gonna be like Microsoft Excel. Put the data in, bam all look fine. But we need a little bit more effort than that to get the results we want as it seems.

    I am still not sure where to paste the java scripts in wordpress though. I tried inputting them into the settings of wpdatatables where there is a section called custom js. But no result. Any suggestions?

  •  2,572
    Aleksandar replied

    Hi again Baran

    I agree that it'd be awesome for a WordPress plugin to work like Excel, but unfortunately Excel is a program that's been developed for over 30 years by Microsoft, and it's gonna take a long time for any other software to catch up with them, especially a WordPress plugin.

    The wpDataChart callbacks can be added to the page itself. If you're using a Gutenberg editor, simply add a Classic Block:

    3190887382.png

    Switch to HTML mode:

    9115485364.png

    And paste the script:

    3514482572.png

    That does it. Some page builders have special blocks for CSS and JS, so you can also do it there.

    I hope that helps.

    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

  • Baran Kaypakoglu replied

    Hello Aleksandar,

    Thank you for you explanation. 

    What I don't understand about the script below is the number inside the bracket: WPDataChartsCallbacks[93]. Where does "93" come from. Because as I see the ID of the table is 12. So how do we refer to our chart or table at hand in the script? 

    I have another question regarding the so called "responsive width" option of the chart. With this option on, rather than the chart filling the width 100%, it is always narrower than my actual content width. Why do you think this might be? Any suggestion regarding this?

    Edit: The chart being narrower than 100%, and I mean not just a little, but in an annoying level of narrow, only exists with Google Charts. HighCharts work fine in this sense.

  •  2,572
    Aleksandar replied

    Ah, sorry for the confusion Baran

    Table's number is 12 in my example, but I forgot to add the chart. Chart's ID is actually "93", so instead of [wpdatatable id=12], there should be [wpdatachart id=93].

    Google Charts have been giving us a lot of issues, when it comes to responsiveness. They lose labels, they lose data, they lose points on the chart. All kinds of mess.

    Their HTML codes are great, but the API they provided in the library doesn't work that good. You could probably solve it with callbacks, but it'd require some time to get everything sorted out.

    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

  • Baran Kaypakoglu replied

    Hi Aleksandar,

    Yes I wish to solve the rest with the callbacks, however, until now I could not get it to work.

    I input the code as you said, replaced the number in brackets with the chart ID, but nothing happens. 

    The script I input in the post is the exact same one in the website backend section which is as below. My chart ID is 6. So I replace the number in brackets as below. 

    I pasted the code before and after the graph, none helped. What am I missing here ?


    <script type="text/javascript">
    jQuery(window).load(function(){   
        if( typeof wpDataChartsCallbacks == 'undefined' ) { wpDataChartsCallbacks = {}; }    
        wpDataChartsCallbacks[6] = function(obj){        
            obj.options.chart.backgroundColor = '#F7F7F7';        
            obj.options.chart.zoomType = 'x';        
            obj.options.chart.panning = true;        
            obj.options.chart.panKey = 'shift';        
            obj.options.tooltip = {            
                formatter: function () {            
                var s = '<b>$' + this.y + '</b>';            
                return s;            
                   }        
        }    
    }
    });
    </script>

    Regards,

    Baran

  •  2,572
    Aleksandar replied

    Hi again Baran

    Are you using the same chart engine?

    This is a callback for Highcharts line chart.

    Can you please provide me the URL to that chart, and I'll remote in to take a look. Just make sure the credentials you left me the other day are still active.

    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

  • Baran Kaypakoglu replied

    Hi Aleksandar,

    Please check the last post at baranstreet.com. I demonstrated the issue there. 

    Thanks,

    Regards,

    Baran

  •  2,572
    Aleksandar replied

    Hi again Baran

    The issue here is that the theme is loading jQuery somewhere in the middle of the page, instead of in the beginning. This is why there are these errors on the page:

    9855540388.png

    I've managed to replicate the issue on my end, and to fix it I added this code to my theme's functions.php file:

    add_action('wp_enqueue_scripts', 'qg_enqueue');
    function qg_enqueue() {
        wp_enqueue_script('jquery');
    }
    

    This resolved the issue with jQuery, and the callbacks were successfully loaded on an exact copy of your table and chart (on my local environment):

    3217856273.png

    Adding stuff to theme's functions.php file can temporarily break the site, so I didn't want to do it without access to FTP. Please do this, and see if the issue is fixed. If not, please provide me FTP access credentials, and I'll gladly do it for you.

    Just don't forget to enable Private reply.

    Kind regards.

    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