lightningchart

How to change font size and color of legendbox entries and chart title


I add the chart title like below

 chart[unique].setTitle(nn).setPadding({
        bottom: -2,
        right: -2,
        top: -36,
        left: -2
    }).setMouseInteractions(false);

How do I set the font size? I tried setFont((font) => font.setSize(12)), but it's not working.

Also I am not able to add it to legendBox:

legendBox["axis"].add(line[name], undefined, ' ').setText(entryname);

I want to set font size and color for chart title and legendbox entries or full legendbox.


Solution

  • ChartXY title font

    LegendBox title and entries can be styled by methods of the LegendBox Builder (setTitle, setEntry):

    const legendBox = ChartXY.addLegendBox(
        LegendBoxBuilders.VerticalLegendBox
            .setTitle((title) => title
                .setFont((font) => font.setFamily('monospace'))
            )
            .setEntry((entry) => entry
                .setFont((font) => font.setSize(10).setStyle('italic'))
            ),
    )
    

    EDIT

    ChartXY title color