Skip to content

Commit e052c3f

Browse files
committed
Add show/hideLegend option to Figure
1 parent ef99162 commit e052c3f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/scala/co/theasi/plotly/Figure.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ trait Figure {
1717
* }}}
1818
*/
1919
def legend(newLegend: LegendOptions): Self =
20-
withNewOptions(options.copy(legendOptions = newLegend))
20+
withNewOptions(options.copy(legendOptions = newLegend, showLegend = Some(true)))
21+
22+
/** Show the legend */
23+
def showLegend(): Self =
24+
withNewOptions(options.copy(showLegend = Some(true)))
25+
26+
/** Hide the legend */
27+
def hideLegend(): Self =
28+
withNewOptions(options.copy(showLegend = Some(false)))
2129

2230
/** Set figure title */
2331
def title(newTitle: String): Self =

src/main/scala/co/theasi/plotly/FigureOptions.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package co.theasi.plotly
33
case class FigureOptions(
44
title: Option[String],
55
legendOptions: LegendOptions,
6+
showLegend: Option[Boolean],
67
margins: Margins,
78
width: Option[Int],
89
height: Option[Int],
@@ -15,6 +16,7 @@ object FigureOptions {
1516
def apply(): FigureOptions = FigureOptions(
1617
title = None,
1718
legendOptions = LegendOptions(),
19+
showLegend = None,
1820
margins = Margins(),
1921
width = None,
2022
height = None,

0 commit comments

Comments
 (0)