Skip to content

One legend for two or more charts (pie) #211

@robertobadjio

Description

@robertobadjio

Hello. Do not get to do one legend on two or more diagrams.
pie2 = r.piechart(545, 440, 25, [0, 22.22, 22.22, 11.11, 44.44]);
pie = r.piechart(490, 540, 25, [0, 0, 12.5, 25, 62.5], {
legend: ["-20%", "21 - 40 %", "41 - 60 %", "61 - 80 %", "81 - 100 %"],
colors: [
"#475664",
"#8C5F66",
"#DB7369",
"#F29961",
"#F0B165"
],
legendpos: "west",
legendothers: "Другие",
});

for(var i = 0, l = pie.labels.length; i < l; i++ ) {
        pie.labels[i].attr("font", "13px sans-serif");
        pie.labels[i].attr("x", 230+20);
        pie.labels[i].attr("cx", 230);
        pie.labels[i].attr("y", 535+i*20);
        pie.labels[i].attr("cy", 535+i*20);
        pie.labels[i][1].attr( "fill", "#000000" );
    }

pie.hover(function () {
this.sector.stop();
this.sector.scale(1.1, 1.1, this.cx, this.cy);

                if (this.label) {
                    this.label[0].stop();
                    this.label[0].attr({ r: 7.5 });
                    this.label[1].attr({ "font-weight": 800 });
                }
            }, function () {
                this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");

                if (this.label) {
                    this.label[0].animate({ r: 5 }, 500, "bounce");
                    this.label[1].attr({ "font-weight": 400 });
                }
            });

            pie2.hover(function () {
                this.sector.stop();
                this.sector.scale(1.1, 1.1, pie2.cx, pie2.cy);

                pie.labels[1].stop();
                pie.labels[1].attr({ r: 7.5 });
                pie.labels[1].attr({ "font-weight": 800 });

            }, function () {
                this.sector.animate({ transform: 's1 1 ' + pie2.cx + ' ' + pie2.cy }, 500, "bounce");

                pie.labels[1].animate({ r: 5 }, 500, "bounce");
                pie.labels[1].attr({ "font-weight": 400 });

            });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions