-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:MetalBlueberry/go-plotly
- Loading branch information
Showing
219 changed files
with
5,534 additions
and
1,726 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
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 @@ | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install numpy | ||
|
||
COPY compute.py . | ||
|
||
CMD ["python", "compute.py"] |
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,14 @@ | ||
IMAGE_NAME = plotly-data-generator | ||
|
||
all: build run | ||
|
||
build: | ||
@docker build -t $(IMAGE_NAME) . | ||
|
||
run: | ||
@docker run --rm $(IMAGE_NAME) | ||
|
||
|
||
|
||
clean: | ||
@docker rmi $(IMAGE_NAME) |
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,33 @@ | ||
import numpy as np | ||
import json | ||
import base64 | ||
|
||
# Generate Z data using NumPy | ||
# Let's create a similar 3x5 matrix with some values | ||
z = np.array([ | ||
[1, np.nan, 30, 50, 1], | ||
[20, 1, 60, 80, 30], | ||
[30, 60, 1, -10, 20] | ||
]) | ||
|
||
|
||
|
||
dtype = z.dtype | ||
bdata = z.tobytes() # Binary data representation | ||
shape = z.shape | ||
|
||
# Encode the binary data as a base64 string | ||
z_bdata_base64 = base64.b64encode(bdata).decode('utf-8') | ||
|
||
# Create the dictionary that represents the JSON object | ||
z_data = { | ||
'dtype': str(dtype), | ||
'shape': shape, | ||
'bdata': z_bdata_base64 | ||
} | ||
|
||
# Convert the dictionary to a JSON object | ||
json_data = json.dumps(z_data, indent=2) | ||
|
||
# Output the JSON object | ||
print(json_data) |
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,52 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"os/exec" | ||
|
||
grob "github.com/MetalBlueberry/go-plotly/generated/v2.31.1/graph_objects" | ||
"github.com/MetalBlueberry/go-plotly/pkg/offline" | ||
"github.com/MetalBlueberry/go-plotly/pkg/types" | ||
) | ||
|
||
func main() { | ||
// https://plotly.com/javascript/heatmaps/ | ||
// var data = [ | ||
// { | ||
// z: [[1, null, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]], | ||
// x: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], | ||
// y: ['Morning', 'Afternoon', 'Evening'], | ||
// type: 'heatmap', | ||
// hoverongaps: false | ||
// } | ||
// ]; | ||
zJSON, err := exec.Command("make").Output() | ||
if err != nil { | ||
panic(err) | ||
} | ||
type bdata struct { | ||
DType types.DType | ||
Shape []int | ||
BData []byte | ||
} | ||
|
||
z := &bdata{} | ||
err = json.Unmarshal(zJSON, z) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fig := &grob.Fig{ | ||
Data: []types.Trace{ | ||
&grob.Heatmap{ | ||
X: types.DataArray([]string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}), | ||
Y: types.DataArray([]string{"Morning", "Afternoon", "Evening"}), | ||
Z: types.BDataArray(z.DType, z.BData, z.Shape), | ||
Hoverongaps: types.False, | ||
}, | ||
}, | ||
} | ||
|
||
offline.Show(fig) | ||
|
||
} |
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
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
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
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
Oops, something went wrong.