Home Forums Chart Support Remove Axis Label altogether

Remove Axis Label altogether

Viewing 3 posts - 1 through 3 (of 3 total)
  • #43224

    Hello,

    I’ve seen in another post how to “hide” an Axis label, but even when hidden a huge space is still used up as if a label is still there.
    I need to remove the label altogether.

    The suggestion given was to use:

    axisY:{
        gridThickness: 0,
        tickLength: 0,
        lineThickness: 0,
        labelFormatter: function(){
          return " ";
        }

    Example given was jsFiddle and you can see how even though the labels/ticks/grids are gone, the space for the label is still there.

    Unfortunately this only gets worse the more Axis you have.
    I’m using 8 different Y axis across 30-ish line series to scale them differently (via min/max values) in the view and each of the labels is leaving a large space behind, and I only really want one of them to be visible.
    My Labels So Far

    Currently I’ve got this for each label (except the visible one) and they still take up space:

                {
                    //index 5
                    labelFontSize: 0,
                    gridThickness:0,
                    tickLength: 0,
                    lineThickness: 0,
                    margin: 0,
                    minimum: -200,
                    maximum: 200,
                    labelPlacement:"inside",
                    labelAutoFit: false,
                    labelFormatter: function(e){
                        return "";
                    }
                },

    Kind of running out of options and not sure if I’m just approaching this from the wrong angle.
    I’m a beginner so I’m not yet aware if there is some CSS id I should be targeting.

    Thank you!
    -Jake

    #43232

    Jake,

    You can prevent the chart to reserve space for the hidden axes by setting negative values to the axis margin as shown in this code snippet below,

    axisY:{
        title: "",
        tickLength: 0,
        lineThickness:0,
        margin:-4,
        labelFormatter: function(e) {
          return "";
       }

    If the solution suggested doesn’t fulfill your requirement, kindly create a JSFiddle with your use case so that we can understand your scenario better and help you out with an appropriate solution.


    Tony Antony
    Team CanvasJS

    #43237

    Ah, such a simple fix, that worked great! I still needed “labelFontSize: 0” to make the numbers disappear, but now the graph lines up clean with the left side with no space lost for hidden labels. Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.