FVANCOP / ChartNew.js

MIT License
420 stars 143 forks source link

Chart disappears when width is to small for legend #451

Closed ghost closed 7 years ago

ghost commented 7 years ago

My chart disappears when the width of the browser window is to small. This happens only when i've a active legend.

I 'fixed' this, with forcing the maxLegendOnLine to have a minimum of 0, using the following code: maxLegendOnLine = Min([Max([Math.floor((availableLegendWidth + Math.ceil(ctx.chartSpaceScale * config.legendSpaceBetweenTextHorizontal)) / (widestLegend + Math.ceil(ctx.chartSpaceScale * config.legendSpaceBetweenTextHorizontal))),1]), config.maxLegendCols]);

My problem right now is that the responsive design isn't working for the legend. Is there any way in the settings to get a wordwrap in the legend when the width is to small or something like this?

FVANCOP commented 7 years ago

Hi,

The chart is not displayed when the width of the window is too small to show something readable (In the code, you can easely find the condition that has been set).

            if( <condition> ) {
                        // draw the chart;
    } else {
        testRedraw(ctx,data,config);
        ctx.firstPass=9;
    }

There is an options associated to responsive chart that reduces or increases automatically the font size of all text (legend included). Set "responsiveScaleContent : true".

see : https://github.com/FVANCOP/ChartNew.js/wiki/100_015_ResponsiveChart#responsivescalecontent

Regards, François