-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Heatmap trace implementation (#148)
- Loading branch information
1 parent
f7dd66d
commit 1d82e3b
Showing
14 changed files
with
240 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package plotly.element | ||
import dataclass.data | ||
|
||
sealed abstract class ColorScale extends Product with Serializable | ||
|
||
object ColorScale { | ||
@data class CustomScale(values: Seq[(Double, Color)]) extends ColorScale | ||
@data class NamedScale(name: String) extends ColorScale | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
demo/src/main/scala/plotly/demo/heatmaps/AnnotatedHeatmap.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package plotly.demo.heatmaps | ||
|
||
import plotly._ | ||
import plotly.demo.DemoChart | ||
import plotly.element._ | ||
import plotly.layout._ | ||
|
||
object AnnotatedHeatmap extends DemoChart { | ||
|
||
def plotlyDocUrl = "https://plot.ly/javascript/heatmaps/#annotated-heatmap" | ||
def id = "annotated-heatmap" | ||
def source = AnnotatedHeatmapSource.source | ||
|
||
// demo source start | ||
|
||
val x = Seq("A", "B", "C", "D", "E"); | ||
val y = Seq("W", "X", "Y", "Z"); | ||
val z = Seq( | ||
Seq(0.00, 0.00, 0.75, 0.75, 0.00), | ||
Seq(0.00, 0.00, 0.75, 0.75, 0.00), | ||
Seq(0.75, 0.75, 0.75, 0.75, 0.75), | ||
Seq(0.00, 0.00, 0.00, 0.75, 0.00) | ||
) | ||
|
||
val data = Seq( | ||
Heatmap( | ||
z=z, x=x, y=y, showscale=false, | ||
colorscale = ColorScale.CustomScale(Seq( | ||
(0, Color.StringColor("#3D9970")), | ||
(1, Color.StringColor("#001f3f")) | ||
)) | ||
) | ||
) | ||
|
||
val layout = Layout( | ||
title = "Annotated Heatmap", | ||
xaxis = Axis(ticks=Ticks.Empty, side=Side.Top), | ||
yaxis = Axis(ticks=Ticks.Empty, ticksuffix=" "), | ||
annotations = for { | ||
(xv, xi) <- x.zipWithIndex; | ||
(yv, yi) <- y.zipWithIndex | ||
} yield Annotation( | ||
x=xv, | ||
y=yv, | ||
xref=Ref.Axis(AxisReference.X1), | ||
yref=Ref.Axis(AxisReference.Y1), | ||
showarrow=false, | ||
text=z(yi)(xi).toString, | ||
font=Font(color=Color.StringColor("white")) | ||
) | ||
) | ||
|
||
// demo source end | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
demo/src/main/scala/plotly/demo/heatmaps/BasicHeatmap.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package plotly.demo.heatmaps | ||
|
||
import plotly._ | ||
import plotly.demo.NoLayoutDemoChart | ||
import plotly.element._ | ||
|
||
object BasicHeatmap extends NoLayoutDemoChart { | ||
|
||
def plotlyDocUrl = "https://plot.ly/javascript/heatmaps/#basic-heatmap" | ||
def id = "basic-heatmap" | ||
def source = BasicHeatmapSource.source | ||
|
||
// demo source start | ||
|
||
val data = Seq( | ||
Heatmap( | ||
z=Seq( | ||
Seq(1, 20, 30), | ||
Seq(20, 1, 60), | ||
Seq(30, 60, 1) | ||
), | ||
colorscale=ColorScale.NamedScale("Portland") | ||
) | ||
) | ||
|
||
// demo source end | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
demo/src/main/scala/plotly/demo/heatmaps/CategoricalAxisHeatmap.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package plotly.demo.heatmaps | ||
|
||
import plotly._ | ||
import plotly.demo.NoLayoutDemoChart | ||
import plotly.element._ | ||
|
||
object CategoricalAxisHeatmap extends NoLayoutDemoChart { | ||
|
||
def plotlyDocUrl = "https://plot.ly/javascript/heatmaps/#heatmap-with-categorical-axis-labels" | ||
def id = "categorical-axis-heatmap" | ||
def source = CategoricalAxisHeatmapSource.source | ||
|
||
// demo source start | ||
|
||
val data = Seq( | ||
Heatmap( | ||
z=Seq( | ||
Seq(1, null.asInstanceOf[Int], 30, 50, 1), | ||
Seq(20, 1, 60, 80, 30), | ||
Seq(30, 60, 1, -10, 20) | ||
), | ||
x=Seq("Monday", "Tuesday", "Wednesday", "Thursday", "Friday"), | ||
y=Seq("Morning", "Afternoon", "Evening"), | ||
) | ||
) | ||
|
||
// demo source end | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
demo/src/main/scala/plotly/demo/heatmaps/CustomColorScaleHeatmap.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package plotly.demo.heatmaps | ||
|
||
import plotly._ | ||
import plotly.demo.NoLayoutDemoChart | ||
import plotly.element._ | ||
|
||
object CustomColorScaleHeatmap extends NoLayoutDemoChart { | ||
|
||
def plotlyDocUrl = "https://plot.ly/javascript/colorscales/#custom-colorscale-for-contour-plot" | ||
def id = "custom-colorscale-heatmap" | ||
def source = CustomColorScaleHeatmapSource.source | ||
|
||
// demo source start | ||
|
||
val data = Seq( | ||
Heatmap( | ||
z=Seq( | ||
Seq(10.0, 10.625, 12.5, 15.625, 20.0), | ||
Seq(5.625, 6.25, 8.125, 11.25, 15.625), | ||
Seq(2.5, 3.125, 5.0, 8.125, 12.5), | ||
Seq(0.625, 1.25, 3.125, 6.25, 10.625), | ||
Seq(0.0, 0.625, 2.5, 5.625, 10.0) | ||
), | ||
colorscale=ColorScale.CustomScale(Seq( | ||
(0, Color.RGB(166,206,227)), | ||
(0.25, Color.RGB(31,120,180)), | ||
(0.45, Color.RGB(178,223,138)), | ||
(0.65, Color.RGB(51,160,44)), | ||
(0.85, Color.RGB(251,154,153)), | ||
(1, Color.RGB(227,26,28)) | ||
)) | ||
) | ||
) | ||
|
||
// demo source end | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,17 @@ if [ -e gh-pages ]; then | |
exit 1 | ||
fi | ||
|
||
sbt demo/fullOptJS | ||
./sbt demo/fullOptJS | ||
mkdir gh-pages | ||
|
||
cp \ | ||
demo/target/scala-2.11/plotly-demo-opt.js \ | ||
demo/target/scala-2.11/plotly-demo-opt.js.map \ | ||
demo/target/scala-2.11/plotly-demo-jsdeps.js \ | ||
demo/target/scala-2.11/plotly-demo-jsdeps.min.js \ | ||
demo/target/scala-2.13/plotly-demo-opt.js \ | ||
demo/target/scala-2.13/plotly-demo-opt.js.map \ | ||
demo/target/scala-2.13/plotly-demo-jsdeps.js \ | ||
demo/target/scala-2.13/plotly-demo-jsdeps.min.js \ | ||
gh-pages | ||
|
||
cat demo/target/scala-2.11/classes/index.html | \ | ||
cat demo/target/scala-2.13/classes/index.html | \ | ||
sed 's@\.\./plotly-demo-jsdeps\[email protected]@' | \ | ||
sed 's@\.\./plotly-demo-fastopt\[email protected]@' | \ | ||
cat > gh-pages/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters