voilab/voilab-pdf-table

Can renderer use two links per cell in a voilab-pdf-table?

Closed this issue · 0 comments

I saw your answer. I already know.

And don't you usually reply to reply?

I mean,
Can renderer use two links per cell in a voilab-pdf-table?

I'm always grateful.

Let me know if there's any other way.

` let betaDivTable = new PdfTable(doc, {
// bottomMargin: 30
});

        betaDivTable
        // add some plugins (here, a 'fit-to-width' for a column)
        .addPlugin(new (require('voilab-pdf-table/plugins/fitcolumn'))({
            column: 'count'
        }))
        .onHeaderAdd(tb => {
            // set header color
            doc
            .font(fonts.Noto.bold1)
            .fillColor('#666668')
        })
        .onHeaderAdded(tb => {
            // reset to standard color
            doc.font(fonts.Noto.light)
        })
        // set defaults to your columns
        .setColumnsDefaults({
            headerBorder: ['T','B'],
            border: ['B'],
            headerBorderOpacity : 1,
            borderOpacity : 0.5,
            padding: [5, 5, 5, 5],
        })
        // add table columns
        .addColumns([
            {
                id: 'beta',
                header: 'Beta Diversity matrices (dm pc) ',
                align: 'center',
                cache: false,
                width: 190,
                // renderer: function (tb, data, draw, column, pos) {
                //     if (draw) {
                //         tb.pdf.fillColor('#666668')
                //         return data.beta;
                //     } else {
                //         return '';
                //     }
                // }
            },
            {
                id: '2d',
                header: '2D plot',
                align: 'center',
                width: 60,
            },
            {
                id: '3d',
                header: '3D plot (Emperor)',
                align: 'center',
                width: 100,
            },
            {
                id: 'tree',
                header: 'UPGMA Tree',
                align: 'center',
                width: 70,
                link: '#',
                caches: false,
                renderer: function (tb, data, draw, column, pos) {
                    if (draw) {
                        tb.pdf.fillColor('#2959a8')
                        
                        //dynamic link
                        column.link = data.treeLink;
                        console.log(data.treeLink)
                        return data.tree;
                    } else {
                        return data.tree;
                    }
                }
            },
        ])
        let betaDivList = [
            {
                "beta": 'Bray-Curtis ( dm pc )',
                "2d": 'Link',
                "3d": 'Link',
                "tree": 'Link',
                "treeLink": mrd.bray_tre,

            },
            {
                "beta": 'Unweighted Unifrac Analysis ( dm pc )',
                "2d": 'Link',
                "3d": 'Link',
                "tree": 'Link',
                "treeLink": mrd.unw_tre,

            },
            {
                "beta": 'Weighted Unifrac Analysis ( dm pc )',
                "2d": 'Link',
                "3d": 'Link',
                "tree": 'Link',
                "treeLink": mrd.wei_tre,
            },
        ];

        betaDivTable.addBody(betaDivList); `

image