How to create two x-axes label using chart.js

前端 未结 3 1940
慢半拍i
慢半拍i 2020-12-16 00:54

There is a way to create two label for y-axes. But how do you make a multiple x-axes label in chart.js? eg: example as in this picture: How to group (two-level) axis labels<

3条回答
  •  时光说笑
    2020-12-16 01:31

    okay maby a bit late ;)

    how can we show the last tick in the second x-axis row?

    with the code from above, we return a empty string. i want to see the label of the last point.

          ticks:{
            callback:function(label){
              var month = label.split(";")[0];
              var year = label.split(";")[1];
              if(month === "February"){
                return year;
              }else{
                return "";  **<==== ???**
              }
    

    thx for the help.

    EDIT

    i change it a bit but not complete like i will i don't want the label at 30 and 31 just the last day w.a.w 31 label , 30 not a label

    month ended at 30 => label

                return month;
              }else if 
                (Nbrday === "31"){
                return month;
              }else if 
                (Nbrday === "30"){
                return month;
              }
                else{
                  // return month;
                return "";
    

提交回复
热议问题