All Apps and Add-ons

Align chart legend legend vertically in advanced xml

subtrakt
Contributor

Hi!

I have a dashboard with 20 rows and 1 column. I really like the legend on the right but the chart buckets don't line up when some of the fields have short values. If i put the legend on the bottom, the chart buckets line up but it doesn't look as good with the legend on the right.

The only work around i can think of is make a macro with an eval statement that adds a bunch of spaces to the right of fields in the timechart so it puts spaces to the right of the value and pushes it over to the left so the chart buckets line up vertically.

That's probably a ridiculous solution so I'd figured I'd ask here!

1 Solution

sideview
SplunkTrust
SplunkTrust

You can control the legend width using the charting properties, but I'm afraid it will only work for the FlashChart module, not for the newer JSChart module. It's not directly documented under the "Chart and Legend" properties, but it says that the Legend is a "TextBlock" and therefore has all the properties of TextBlocks, which are listed here - http://docs.splunk.com/Documentation/Splunk/6.1.1/AdvancedDev/AdvChartingConfig-TextblockLayoutsprit... Among which are maximumWidth and minimumWidth.

As to why it doesn't work in JSChart, I think it's a pretty general state of affairs, in that there are quite a lot of FlashChart charting keys that JSChart still doesn't support.

But switch to FlashChart and put this ValueSetter module upstream from your FlashChart module and all the legends will be exactly 200px wide.

<module name="ValueSetter">
  <param name="arg.charting.legend.labelStyle.maximumWidth">200</param>
  <param name="arg.charting.legend.labelStyle.minimumWidth">200</param>

View solution in original post

sideview
SplunkTrust
SplunkTrust

You can control the legend width using the charting properties, but I'm afraid it will only work for the FlashChart module, not for the newer JSChart module. It's not directly documented under the "Chart and Legend" properties, but it says that the Legend is a "TextBlock" and therefore has all the properties of TextBlocks, which are listed here - http://docs.splunk.com/Documentation/Splunk/6.1.1/AdvancedDev/AdvChartingConfig-TextblockLayoutsprit... Among which are maximumWidth and minimumWidth.

As to why it doesn't work in JSChart, I think it's a pretty general state of affairs, in that there are quite a lot of FlashChart charting keys that JSChart still doesn't support.

But switch to FlashChart and put this ValueSetter module upstream from your FlashChart module and all the legends will be exactly 200px wide.

<module name="ValueSetter">
  <param name="arg.charting.legend.labelStyle.maximumWidth">200</param>
  <param name="arg.charting.legend.labelStyle.minimumWidth">200</param>

the_wolverine
Champion

It didn't work for me as a ValueSetter module, but I got it work using these params in HiddenChartFormatter (with FlashChart):

 <param name="charting.legend.labelStyle.maximumWidth">200</param>
 <param name="charting.legend.labelStyle.minimumWidth">200</param>
0 Karma

snoobzilla
Builder

Thanks. Wish this worked with JSChart... flashchart doesn't work on my phone.

0 Karma
Get Updates on the Splunk Community!

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...