Skip to content

Add cadlestick chart #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions core/shared/src/main/scala/plotly/Trace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ object Bar {
Option(xaxis),
Option(yaxis),
Option(error_y),
Option(showlegend).map(b => b: Boolean),
Option(showlegend) .map(b => b: Boolean),
Option(hoverinfo),
Option(textposition),
Option(opacity).map(d => d: Double),
Option(opacity) .map(d => d: Double),
Option(width),
Option(base)
)
Expand Down Expand Up @@ -316,9 +316,50 @@ object Heatmap {
Option(y),
Option(x),
Option(z),
Option(autocolorscale).map(b => b: Boolean),
Option(autocolorscale) .map(b => b: Boolean),
Option(colorscale),
Option(showscale).map(b => b: Boolean),
Option(showscale) .map(b => b: Boolean),
Option(name)
)
}

@data(optionSetters = true) class Candlestick(
x: Option[Sequence] = None,
close: Option[Sequence] = None,
high: Option[Sequence] = None,
low: Option[Sequence] = None,
open: Option[Sequence] = None,
decreasing: Option[Marker] = None,
increasing: Option[Marker] = None,
line: Option[Marker] = None,
xaxis: Option[AxisReference] = None,
yaxis: Option[AxisReference] = None
) extends Trace

object Candlestick {
@deprecated("Use Candlestick() and chain-call .with* methods on it instead", "0.8.0")
def apply(
x: Sequence = null,
close: Sequence = null,
high: Sequence = null,
low: Sequence = null,
open: Sequence = null,
decreasing: Marker = null,
increasing: Marker = null,
line: Marker = null,
xaxis: AxisReference = null,
yaxis: AxisReference = null
): Candlestick =
Candlestick(
Option(x),
Option(close),
Option(high),
Option(low),
Option(open),
Option(decreasing),
Option(increasing),
Option(line),
Option(xaxis),
Option(yaxis)
)
}
5 changes: 3 additions & 2 deletions core/shared/src/main/scala/plotly/element/Color.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ object Color {
"blue",
"cls", // ???
"pink",
"green"
"green",
"magenta"
)
}

@data class RGB(r: Int, g: Int, b: Int) extends Color

@data class HSL(h: Int, s: Int, l: Int) extends Color
}
}
14 changes: 10 additions & 4 deletions core/shared/src/main/scala/plotly/layout/Annotation.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package plotly
package layout

import java.lang.{ Boolean => JBoolean }
import java.lang.{ Boolean => JBoolean, Double => JDouble }

import dataclass.data
import plotly.element._
Expand All @@ -15,7 +15,9 @@ import plotly.element._
yanchor: Option[Anchor] = None,
text: Option[Element] = None,
font: Option[Font] = None,
showarrow: Option[Boolean] = None
showarrow: Option[Boolean] = None,
ax: Option[Double] = None,
ay: Option[Double] = None
)

object Annotation {
Expand All @@ -29,7 +31,9 @@ object Annotation {
yanchor: Anchor = null,
text: Element = null,
font: Font = null,
showarrow: JBoolean = null
showarrow: JBoolean = null,
ax: JDouble = null,
ay: JDouble = null
): Annotation =
Annotation(
Option(xref),
Expand All @@ -40,6 +44,8 @@ object Annotation {
Option(yanchor),
Option(text),
Option(font),
Option(showarrow).map(v => v: Boolean)
Option(showarrow).map(v => v: Boolean),
Option(ax).map(x => x: Double),
Option(ay).map(x => x: Double)
)
}
13 changes: 8 additions & 5 deletions core/shared/src/main/scala/plotly/layout/Axis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import plotly.element._
zeroline: Option[Boolean] = None,
zerolinewidth: Option[Double] = None,
zerolinecolor: Option[Color] = None,
range: Option[(Double, Double)] = None,
range: Option[Sequence] = None,
autorange: Option[Boolean] = None,
ticks: Option[Ticks] = None,
domain: Option[(Double, Double)] = None,
Expand All @@ -41,7 +41,8 @@ import plotly.element._
tickvals: Option[Sequence] = None,
ticktext: Option[Sequence] = None,
nticks: Option[Int] = None,
automargin: Option[Boolean] = None
automargin: Option[Boolean] = None,
rangeslider: Option[RangeSlider],
)

object Axis {
Expand All @@ -68,7 +69,7 @@ object Axis {
zeroline: JBoolean = null,
zerolinewidth: JDouble = null,
zerolinecolor: Color = null,
range: (Double, Double) = null,
range: Sequence = null,
autorange: JBoolean = null,
ticks: Ticks = null,
domain: (Double, Double) = null,
Expand All @@ -81,7 +82,8 @@ object Axis {
tickvals: Sequence = null,
ticktext: Sequence = null,
nticks: JInt = null,
automargin: JBoolean = null
automargin: JBoolean = null,
rangeslider: RangeSlider = null
): Axis =
Axis(
Option(title),
Expand Down Expand Up @@ -118,6 +120,7 @@ object Axis {
Option(tickvals),
Option(ticktext),
Option(nticks) .map(x => x: Int),
Option(automargin) .map(x => x: Boolean)
Option(automargin) .map(x => x: Boolean),
Option(rangeslider)
)
}
13 changes: 9 additions & 4 deletions core/shared/src/main/scala/plotly/layout/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import plotly.element._
bargroupgap: Option[Double] = None,
hovermode: Option[HoverMode] = None,
boxmode: Option[BoxMode] = None,
scene: Option[Scene] = None

scene: Option[Scene] = None,
dragmode: Option[String],
shapes: Option[Seq[Shape]]
)

object Layout {
Expand Down Expand Up @@ -66,7 +67,9 @@ object Layout {
bargroupgap: JDouble = null,
hovermode: HoverMode = null,
boxmode: BoxMode = null,
scene: Scene = null
scene: Scene = null,
dragmode: String = null,
shapes: Seq[Shape] = null
): Layout =
new Layout(
Option(title),
Expand Down Expand Up @@ -95,6 +98,8 @@ object Layout {
Option(bargroupgap).map(x => x),
Option(hovermode),
Option(boxmode),
Option(scene)
Option(scene),
Option(dragmode),
Option(shapes)
)
}
11 changes: 11 additions & 0 deletions core/shared/src/main/scala/plotly/layout/RangeSlider.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package plotly.layout

import dataclass.data
import plotly.Sequence

@data class RangeSlider(
range: Option[Sequence]
)
object RangeSlider {
def apply(range: Sequence = null): RangeSlider = RangeSlider(Option(range))
}
17 changes: 17 additions & 0 deletions core/shared/src/main/scala/plotly/layout/Shape.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package plotly.layout

import dataclass.data
import plotly.element.{Color, Line}

@data class Shape (
`type`: Option[String],
xref: Option[String],
yref: Option[String],
x0: Option[String],
y0: Option[Double],
x1: Option[String],
y1: Option[Double],
fillcolor: Option[Color],
opacity: Option[Double],
line: Option[Line],
)
2 changes: 2 additions & 0 deletions tests/src/test/scala/plotly/doc/DocumentationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ class DocumentationTests extends AnyFlatSpec with Matchers {
"basic/horizontal-bar",
// TODO? Pie charts
"financial/time-series",
"financial/candlestick-charts",
// "financial/ohlc",
"basic/bubble",
"basic/area",
"layout/sizing",
Expand Down