Okay
  Public Ticket #913100
HighCharts styling question
Closed

Comments

  •  2
    Alan started the conversation

    Hi there wpDataTables gang / Milos ,

    Congratulations on the latest release !  It's very handy for me personally when it comes to highcharts.

    I again have a question with regard to styling highcharts, as I can not for the life of me figure out why my additions to wpdatatables_highcharts.js  keep overriding certain values.  The problem is simple , whenever I make any changes to yAxis or xAxis elements all existing values go to default / nulled out.

    For example.  If I add this bit of code

     this.options.xAxis={

                        
                            plotLines: [{
                            color: 'grey',
                            width: 2,
                            value: 14.5,
                            label: {
                            text: 'Major Event',
                            verticalAlign: 'top',
                            textAlign: 'center',
                            style: {
                            color: 'grey',
                            fontWeight: 'bold',
                            }}}]
                        };

    all my previous xAxis labels and titles go to default / null. Default in this case means my quarterly labels (2015-Q2) just become integers (12).  

    Pic attached has the original theme on the left (inside green border) , while the edit (inside red border) is on the right .  You can see the plot line (on the right) gets included correctly but how do I retain the original labels and titles?

    Same thing happens when I insert any yAxis code. 

    I'm sure this is pretty much the same issue as my previous ticket (877562) Milos, but after trying a lot of combinations of code I thought it might be better to ask the experts.

    I know I'm missing something small, but I just can not figure it out .


    Thank you.




  • [deleted] replied

    Hi Alan,

    Can you send me a link of your original chart? Did you tried to edit wpdatatables_highcharts.js or you tried to use callback? Is a option for you to use wpDataChart callback to customize chart options that are not available with built-in functionalities - Link?

    As I understand you tried to apply these options to your original chart (with green border from attachment)?

    this.options.xAxis={
        plotLines: [{
        color: 'grey',
        width: 2,
        value: 14.5,
        label: {
        text: 'Major Event',
        verticalAlign: 'top',
        textAlign: 'center',
        style: {
            color: 'grey',
            fontWeight: 'bold',
        }}}
        ]
    };
    
  •  2
    Alan replied

    Hi Milos,

    Thank you for your quick reply. Your support is fantastic and greatly appreciated. 

    Here is the chart in question with the before and after edits, where you can see the values that change or get zapped.

    Regarding your suggestion on wpDataChart callbacks.  That's how I was working originally but for my workflow this represents a few issues, namely the amount of charts/pages  that this would need to apply to (800 projects with 4 charts each) .  Granted it would all be the same code.  

    Also , we build and change all these project pages using WP All Import and the code for jQuery snipet gets encoded (when you look at the page as text), which represents another level of complexity that I probably want to avoid. 

    For me it would be much neater just to have this all done inside wpdatatables_highcharts.js as all these spline charts will carry the exact same styling.  

    In my  previous ticket (877562), which had similar issues,  you showed me how to break up that code into discrete lines.  I tried to replicate that in this case , but am not sure how to structure it as there are no specific examples, so I haven't had much luck.

    Thanks again.

    Kind regards

    Alan K.

  •  2
    Alan replied

    Hi Milos,

    I'll get you that link to the original chart asap, sorry I missed that part.  I'm working locally at this stage so I'll need to set that up for you.

    Kind regards

    Alan K.

  • [deleted] replied

    Hi Alan,

    Where did you add code for xAxis in wpdatatables_highcharts.js?

     Maybe you can try with this so you will not override whole xAxis options:

    this.options.xAxis.plotLines = [{
          color: 'grey',
          width: 2,
          value: 14.5,
          label: {
                text: 'Major Event',
                verticalAlign: 'top',
                textAlign: 'center',
                style: {
                      color: 'grey',
                      fontWeight: 'bold',
                }
          }
    }];
    
  •  2
    Alan replied

    Heya Milos,

    That's worked perfectly , thank you a heap for your help.  I can not believe I did not work that out for myself.  Believe me I tried.  

    FYI, all my code sits in between these lines in wpdatatables_highcharts.js


    case 'highcharts_line_chart':
    default: ------------ CODE --------------- break;

    It all works now, including my yAxis edits so I think you've totally sorted me out with regard to the code and how I need to structure it in order to NOT override the default values.  

    Thanks again.

    If you're ever in Melbourne  I will need to buy you a few beers :)


    Kind regards

    Alan K.




  • [deleted] replied

    Hi Alan,

    You are welcome