Skip to content
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

Add new properties for Histogram and layout.Axis #432

Merged
merged 7 commits into from
May 13, 2024
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# activate meaningful git annotations with:
# git config blame.ignoreRevsFile .git-blame-ignore-revs

# scalafmt
0ad886c35bdf9c8ad2bfb0501070b8b2ce810710
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
SCALA_VERSION: ["2.12.17", "2.13.10"]
SCALA_VERSION: ["2.12.19", "2.13.14"]
steps:
- uses: actions/checkout@v3
- uses: coursier/cache-action@v6
Expand Down
27 changes: 27 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version = "3.8.1"

runner.dialect = scala213

preset = defaultWithAlign

maxColumn = 120

assumeStandardLibraryStripMargin = true

align {
arrowEnumeratorGenerator = true
}

newlines {
penalizeSingleSelectMultiArgList = true
}

rewrite {
rules = [Imports, PreferCurlyFors, RedundantParens]
imports.sort = scalastyle
}

docstrings.wrap=no

// only format files tracked by git
project.git = true
220 changes: 110 additions & 110 deletions almond/src/main/scala/plotly/Almond.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ object Almond {

val requireInit =
if (offline)
s"""define('plotly', function(require, exports, module) {
| ${Plotly.plotlyMinJs}
|});
s"""define('plotly', function(require, exports, module) {
| ${Plotly.plotlyMinJs}
|});
""".stripMargin
else
s"""require.config({
| paths: {
| d3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min',
| plotly: 'https://cdn.plot.ly/plotly-${Plotly.plotlyVersion}.min',
| jquery: 'https://code.jquery.com/jquery-3.3.1.min'
| },
|
| shim: {
| plotly: {
| deps: ['d3', 'jquery'],
| exports: 'plotly'
| }
| }
|});
| paths: {
| d3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min',
| plotly: 'https://cdn.plot.ly/plotly-${Plotly.plotlyVersion}.min',
| jquery: 'https://code.jquery.com/jquery-3.3.1.min'
| },
|
| shim: {
| plotly: {
| deps: ['d3', 'jquery'],
| exports: 'plotly'
| }
| }
|});
""".stripMargin

val html = s"""
Expand All @@ -57,12 +57,12 @@ object Almond {
}

def plotJs(
data: Seq[Trace],
layout: Layout,
config: Config,
div: String = ""
data: Seq[Trace],
layout: Layout,
config: Config,
div: String = ""
)(implicit
publish: OutputHandler
publish: OutputHandler
): String = {

val (div0, divPart) =
Expand All @@ -73,12 +73,12 @@ object Almond {
(div, "")

val baseJs = Plotly.jsSnippet(div0, data, layout, config)
val json = Plotly.jsonSnippet(data, layout, config)
val json = Plotly.jsonSnippet(data, layout, config)

val js =
s"""require(['plotly'], function(Plotly) {
| $baseJs
|});
s"""require(['plotly'], function(Plotly) {
| $baseJs
|});
""".stripMargin

val data0 = DisplayData(
Expand All @@ -100,12 +100,12 @@ object Almond {
almond.display.UpdatableDisplay.generateDiv("plot-")

def plot(
data: Seq[Trace],
layout: Layout = Layout(),
config: Config = Config(),
div: String = ""
data: Seq[Trace],
layout: Layout = Layout(),
config: Config = Config(),
div: String = ""
)(implicit
publish: OutputHandler
publish: OutputHandler
): String = {

if (!Internal.initialized)
Expand All @@ -123,39 +123,39 @@ object Almond {

@deprecated("Create a Layout and / or a Config, and call one of the other plot methods instead", "0.8.0")
def plot(
title: String = null,
legend: Legend = null,
width: JInt = null,
height: JInt = null,
showlegend: JBoolean = null,
xaxis: Axis = null,
yaxis: Axis = null,
xaxis1: Axis = null,
xaxis2: Axis = null,
xaxis3: Axis = null,
xaxis4: Axis = null,
yaxis1: Axis = null,
yaxis2: Axis = null,
yaxis3: Axis = null,
yaxis4: Axis = null,
barmode: BarMode = null,
autosize: JBoolean = null,
margin: Margin = null,
annotations: Seq[Annotation] = null,
plot_bgcolor: Color = null,
paper_bgcolor: Color = null,
font: Font = null,
bargap: JDouble = null,
bargroupgap: JDouble = null,
hovermode: HoverMode = null,
boxmode: BoxMode = null,
editable: JBoolean = null,
responsive: JBoolean = null,
showEditInChartStudio: JBoolean = null,
plotlyServerURL: String = null,
div: String = ""
title: String = null,
legend: Legend = null,
width: JInt = null,
height: JInt = null,
showlegend: JBoolean = null,
xaxis: Axis = null,
yaxis: Axis = null,
xaxis1: Axis = null,
xaxis2: Axis = null,
xaxis3: Axis = null,
xaxis4: Axis = null,
yaxis1: Axis = null,
yaxis2: Axis = null,
yaxis3: Axis = null,
yaxis4: Axis = null,
barmode: BarMode = null,
autosize: JBoolean = null,
margin: Margin = null,
annotations: Seq[Annotation] = null,
plot_bgcolor: Color = null,
paper_bgcolor: Color = null,
font: Font = null,
bargap: JDouble = null,
bargroupgap: JDouble = null,
hovermode: HoverMode = null,
boxmode: BoxMode = null,
editable: JBoolean = null,
responsive: JBoolean = null,
showEditInChartStudio: JBoolean = null,
plotlyServerURL: String = null,
div: String = ""
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
plot(
Layout(
Expand Down Expand Up @@ -195,77 +195,77 @@ object Almond {
)

def plot(
layout: Layout,
config: Config,
div: String
layout: Layout,
config: Config,
div: String
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
Almond.plot(Seq(data), layout, config, div = div)

def plot()(implicit
publish: OutputHandler
publish: OutputHandler
): String =
plot(Layout(), Config(), "")

def plot(
layout: Layout
layout: Layout
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
plot(layout, Config(), "")

def plot(
config: Config
config: Config
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
plot(Layout(), config, "")

def plot(
layout: Layout,
config: Config
layout: Layout,
config: Config
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
plot(layout, config, "")
}

implicit class DataSeqOps(val data: Seq[Trace]) extends AnyVal {
def plot(
title: String = null,
legend: Legend = null,
width: JInt = null,
height: JInt = null,
showlegend: JBoolean = null,
xaxis: Axis = null,
yaxis: Axis = null,
xaxis1: Axis = null,
xaxis2: Axis = null,
xaxis3: Axis = null,
xaxis4: Axis = null,
yaxis1: Axis = null,
yaxis2: Axis = null,
yaxis3: Axis = null,
yaxis4: Axis = null,
barmode: BarMode = null,
autosize: JBoolean = null,
margin: Margin = null,
annotations: Seq[Annotation] = null,
plot_bgcolor: Color = null,
paper_bgcolor: Color = null,
font: Font = null,
bargap: JDouble = null,
bargroupgap: JDouble = null,
hovermode: HoverMode = null,
boxmode: BoxMode = null,
editable: JBoolean = null,
responsive: JBoolean = null,
showEditInChartStudio: JBoolean = null,
plotlyServerURL: String = null,
div: String = ""
title: String = null,
legend: Legend = null,
width: JInt = null,
height: JInt = null,
showlegend: JBoolean = null,
xaxis: Axis = null,
yaxis: Axis = null,
xaxis1: Axis = null,
xaxis2: Axis = null,
xaxis3: Axis = null,
xaxis4: Axis = null,
yaxis1: Axis = null,
yaxis2: Axis = null,
yaxis3: Axis = null,
yaxis4: Axis = null,
barmode: BarMode = null,
autosize: JBoolean = null,
margin: Margin = null,
annotations: Seq[Annotation] = null,
plot_bgcolor: Color = null,
paper_bgcolor: Color = null,
font: Font = null,
bargap: JDouble = null,
bargroupgap: JDouble = null,
hovermode: HoverMode = null,
boxmode: BoxMode = null,
editable: JBoolean = null,
responsive: JBoolean = null,
showEditInChartStudio: JBoolean = null,
plotlyServerURL: String = null,
div: String = ""
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
plot(
Layout(
Expand Down Expand Up @@ -305,11 +305,11 @@ object Almond {
)

def plot(
layout: Layout,
config: Config,
div: String
layout: Layout,
config: Config,
div: String
)(implicit
publish: OutputHandler
publish: OutputHandler
): String =
Almond.plot(data, layout, config, div = div)
}
Expand Down
Loading
Loading