Home Forums Feature Requests & Feedback Responsive Font Size – IndexLabelFontSize

Responsive Font Size – IndexLabelFontSize

Viewing 2 posts - 1 through 2 (of 2 total)
  • #20558

    Is there a way that font size can be change responsively when browser window is adjusted.
    Currently indexLabelFontSize is set to be 36;
    When chart changes in size, the font size stays the same.

    Please see the jsfiddle provided.
    https://jsfiddle.net/QwZuf/1171/

    #20570

    Ryan,

    Font size remains the same even after resize as you are setting indexLabelFontSize to 36. You can change indexLabelFontSize on resize of window and relate it to chart-container width and can have minimum and maximum limits on the same.

    Kindly take a look at the code-snippet below,

    $(window).resize(function() {
    		
        for(var i = 0; i < chart.options.data.length; i++){
    	chart.options.data[i].indexLabelFontSize = Math.min(36, Math.max( 12, $("#chartContainer").width() / 10));  
        }
        chart.render();
    }); 

    Please take a look at this updated jsfiddle.

    responsive index label font size


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.