c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Line chart hides when it have to be shown

Open format1981 opened this issue 12 years ago • 2 comments

http://jsfiddle.net/wyrv2c4w/ Open this demo and try to hide data2 by clicking data2 under the chart. So data1 line will not shown. This bug appears in chrome and opera. Firefox and IE11 - OK.

format1981 avatar Sep 11 '14 16:09 format1981

I fix it by adding 2 strings, but i dont know is it correct or not.

c3_chart_fn.show = function (targetIds, options) {
        var $$ = this.internal;

        targetIds = $$.mapToTargetIds(targetIds);
        options = options || {};

        $$.removeHiddenTargetIds(targetIds);
        $$.svg.selectAll($$.selectorTargets(targetIds))
            .transition()
            .style('opacity', 1)
            .style('display', ''); // FIX STRING

        if (options.withLegend) {
            $$.showLegend(targetIds);
        }

        $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true});
    };

    c3_chart_fn.hide = function (targetIds, options) {
        var $$ = this.internal;

        targetIds = $$.mapToTargetIds(targetIds);
        options = options || {};

        $$.addHiddenTargetIds(targetIds);
        $$.svg.selectAll($$.selectorTargets(targetIds))
            .transition()
            .style('opacity', 0)
            .style('display', 'none'); // FIX STRING 2

        if (options.withLegend) {
            $$.hideLegend(targetIds);
        }

        $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true});
    };

format1981 avatar Sep 11 '14 18:09 format1981

Thank you for reporting. This seems to happen when the difference between data to be shown and hide is huge (if data1 includes over 400, this seems not happen). However, as you investigated, I think this is a kind of bug derived from the browser, so I don't want to apply this fix simply. Also this effects default animation of other types of chart. I will looking into more, so please give me some time.

masayuki0812 avatar Sep 23 '14 11:09 masayuki0812