# EasyChart legend: increase key line width and change colours

**URL:** <https://forum.inductiveautomation.com/t/easychart-legend-increase-key-line-width-and-change-colours/15337>\
**Category:** Ignition\
**Created:** [September 14, 2017, 12:42am UTC](https://forum.inductiveautomation.com/t/easychart-legend-increase-key-line-width-and-change-colours/15337 "2017-09-14T00:42:31Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 14, 2017, 7:24pm UTC](https://forum.inductiveautomation.com/t/easychart-legend-increase-key-line-width-and-change-colours/15337/6 "2017-09-14T19:24:43Z")

</div>

Well, that ended up being _way_ more involved than I figured it would be. But because I enjoyed myself:  
(Preemptive disclaimer: Don’t even think of trying to call in to support if this doesn’t work for you)

```auto
	from org.jfree.chart.renderer.xy import XYLineAndShapeRenderer
	from org.jfree.chart import LegendItem
	legend = chart.getLegend()
	plot = chart.getPlot()
	renderer = plot.getRenderer()
	
	class CustomRenderer(XYLineAndShapeRenderer):
		def getLegendItem(self, dataset, series):
			original = renderer.getLegendItem(dataset, series)
			new = LegendItem(
				original.getLabel(),
				original.getDescription(),
				original.getToolTipText(),
				"", #urlText
				original.getShape(),
				original.getLinePaint(), #set fill paint to line paint
				original.getOutlineStroke(),
				original.getOutlinePaint()
			)
			new.setSeriesIndex(series)
			new.setDatasetIndex(dataset)
			return new
		
		def getLegendItems(self):
			collection = XYLineAndShapeRenderer.getLegendItems(self)
			for ds in range(plot.getDatasetCount()):
				for series in range(plot.getSeriesCount()):
					legend = self.getLegendItem(ds, series)
					collection.add(legend)
			return collection
			
	newRenderer = CustomRenderer(True, False)
	newRenderer.setBaseSeriesVisibleInLegend(True)
	legend.setSources([newRenderer])

```

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7a55b3022738415a3c5c901cb0d0c06a3467f4b1.png)

---

_[View the full topic](https://forum.inductiveautomation.com/t/easychart-legend-increase-key-line-width-and-change-colours/15337)._
