Reteras
Reteras

Reputation: 89

Is the length of the text in a nvd3-legend adjustable?

I'm using d3 and nvd3 to visualize some data in a graph. Now, no matter how many graphs i have, the legend above the (line)graph will always be shortened with trailing dots at the end. Example of the legend with trailing dots Is there a way to adjust the legend in a fairly comfortable way? If so, how would i adress the legend and its properties?

Upvotes: 0

Views: 1048

Answers (3)

Shobana VK
Shobana VK

Reputation: 389

legend: {
      maxKeyLength: 100,
      padding: 40
    }

This will set maximum text length of legend as 100 and ensures text cut off due to ellipsis.

Upvotes: 1

Andrea Martines
Andrea Martines

Reputation: 41

Thanks Reteras it did the trick for my PieChart, here are my legend chart options (typescript version)

Just change the margin to adjust the position

    legend: {
      align: false,
      height: 200,
      margin: {
        right: 50,
        top: 25,
        left:0
      }
   }
 legendPosition: 'right',

Upvotes: 2

Reteras
Reteras

Reputation: 89

I found the answer myself. To keep the text from shortening, you can use chart.legend.align(false)

Upvotes: 2

Related Questions