Skip to content

Commit b5e8360

Browse files
Added a panel wrapper
1 parent 5b42e88 commit b5e8360

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/main/scala/demo/components/piechart.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package demo.components
22

33
import scala.scalajs.js
44
import japgolly.scalajs.react._
5-
// import japgolly.scalajs.react.vdom.all._
5+
import japgolly.scalajs.react.vdom.all.key
66
import japgolly.scalajs.react.vdom.svg.all._
77
import paths.high.Pie
88

@@ -15,7 +15,7 @@ object piechart {
1515
private def move(p: js.Array[Double]) = s"translate(${ p(0) },${ p(1) })"
1616
private val palette = mix(Color(130, 140, 210), Color(180, 205, 150))
1717

18-
val PieChart = ReactComponentB[List[Country]]("Item list")
18+
val PieChart = ReactComponentB[List[Country]]("Pie chart")
1919
.render(countries => {
2020
val pie = Pie[Country](
2121
data = countries,
@@ -25,7 +25,7 @@ object piechart {
2525
center = (0, 0)
2626
)
2727
val slices = pie.curves map { curve =>
28-
g(
28+
g(key := curve.item.name)(
2929
lineargradient(
3030
id := s"grad-${ curve.index }",
3131
stop(stopColor := string(palette(curve.index)), offset := "0%"),

src/main/scala/demo/components/toplevel.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package demo.components
33
import japgolly.scalajs.react._
44
import japgolly.scalajs.react.vdom.all._
55

6+
import panel._
67
import piechart._
78

89

@@ -19,7 +20,11 @@ object toplevel {
1920
.render(_ =>
2021
div(className := "container",
2122
div(className := "row",
22-
div(className := "col-md-6", id := "pie", PieChart(countries))
23+
Panel(PanelContent(
24+
id = Some("pie"),
25+
title = "Pie Chart",
26+
text = "Here is a pie chart example. Sectors are clickable"
27+
), PieChart(countries))
2328
)
2429
)
2530
)

0 commit comments

Comments
 (0)