Skip to content

Commit

Permalink
allow usage of frames
Browse files Browse the repository at this point in the history
  • Loading branch information
pafo committed May 12, 2024
1 parent 6aa6e62 commit 1492cb7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
18 changes: 15 additions & 3 deletions generated/v2.19.0/graph_objects/plotly_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ type Trace interface {
// Traces is a slice of Traces
type Traces []Trace

type Frame struct {
Name string `json:"name"`
Data []Trace `json:"data"`
Layout interface{} `json:"layout"` //'Layout properties which this frame modifies. The format is identical to the normal layout definition.'
}

// Fig is the base type for figures.
type Fig struct {
// Data The data to be plotted is described in an array usually called data, whose elements are trace objects of various types (e.g. scatter, bar etc) as documented in the Full Reference.
Expand All @@ -33,6 +39,9 @@ type Fig struct {

// Animation is not yet implemented, feel free to insert custom a struct
Animation interface{} `json:"animation,omitempty"`

// Frames is not yet implemented, feel free to insert custom a struct
Frames []Frame `json:"frames,omitempty"`
}

// AddTraces Is a shorthand to add figures to a given figure. It handles the case where the Traces value is nil.
Expand All @@ -44,6 +53,7 @@ func (fig *Fig) AddTraces(traces ...Trace) {
}

// UnmarshalJSON is a custom unmarshal function to properly handle special cases.
// unmarshal skips frames and animations
func (fig *Fig) UnmarshalJSON(data []byte) error {
var err error
tmp := unmarshalFig{}
Expand All @@ -66,9 +76,11 @@ func (fig *Fig) UnmarshalJSON(data []byte) error {
}

type unmarshalFig struct {
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Animation interface{} `json:"animation,omitempty"`
Frames []Frame `json:"frames,omitempty"`
}

// Bool represents a *bool value. Needed to tell the differenc between false and nil.
Expand Down
18 changes: 15 additions & 3 deletions generated/v2.29.1/graph_objects/plotly_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ type Trace interface {
// Traces is a slice of Traces
type Traces []Trace

type Frame struct {
Name string `json:"name"`
Data []Trace `json:"data"`
Layout interface{} `json:"layout"` //'Layout properties which this frame modifies. The format is identical to the normal layout definition.'
}

// Fig is the base type for figures.
type Fig struct {
// Data The data to be plotted is described in an array usually called data, whose elements are trace objects of various types (e.g. scatter, bar etc) as documented in the Full Reference.
Expand All @@ -33,6 +39,9 @@ type Fig struct {

// Animation is not yet implemented, feel free to insert custom a struct
Animation interface{} `json:"animation,omitempty"`

// Frames is not yet implemented, feel free to insert custom a struct
Frames []Frame `json:"frames,omitempty"`
}

// AddTraces Is a shorthand to add figures to a given figure. It handles the case where the Traces value is nil.
Expand All @@ -44,6 +53,7 @@ func (fig *Fig) AddTraces(traces ...Trace) {
}

// UnmarshalJSON is a custom unmarshal function to properly handle special cases.
// unmarshal skips frames and animations
func (fig *Fig) UnmarshalJSON(data []byte) error {
var err error
tmp := unmarshalFig{}
Expand All @@ -66,9 +76,11 @@ func (fig *Fig) UnmarshalJSON(data []byte) error {
}

type unmarshalFig struct {
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Animation interface{} `json:"animation,omitempty"`
Frames []Frame `json:"frames,omitempty"`
}

// Bool represents a *bool value. Needed to tell the differenc between false and nil.
Expand Down
18 changes: 15 additions & 3 deletions generated/v2.31.1/graph_objects/plotly_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ type Trace interface {
// Traces is a slice of Traces
type Traces []Trace

type Frame struct {
Name string `json:"name"`
Data []Trace `json:"data"`
Layout interface{} `json:"layout"` //'Layout properties which this frame modifies. The format is identical to the normal layout definition.'
}

// Fig is the base type for figures.
type Fig struct {
// Data The data to be plotted is described in an array usually called data, whose elements are trace objects of various types (e.g. scatter, bar etc) as documented in the Full Reference.
Expand All @@ -33,6 +39,9 @@ type Fig struct {

// Animation is not yet implemented, feel free to insert custom a struct
Animation interface{} `json:"animation,omitempty"`

// Frames is not yet implemented, feel free to insert custom a struct
Frames []Frame `json:"frames,omitempty"`
}

// AddTraces Is a shorthand to add figures to a given figure. It handles the case where the Traces value is nil.
Expand All @@ -44,6 +53,7 @@ func (fig *Fig) AddTraces(traces ...Trace) {
}

// UnmarshalJSON is a custom unmarshal function to properly handle special cases.
// unmarshal skips frames and animations
func (fig *Fig) UnmarshalJSON(data []byte) error {
var err error
tmp := unmarshalFig{}
Expand All @@ -66,9 +76,11 @@ func (fig *Fig) UnmarshalJSON(data []byte) error {
}

type unmarshalFig struct {
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Animation interface{} `json:"animation,omitempty"`
Frames []Frame `json:"frames,omitempty"`
}

// Bool represents a *bool value. Needed to tell the differenc between false and nil.
Expand Down
18 changes: 15 additions & 3 deletions generator/templates/plotly.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ type Trace interface {
// Traces is a slice of Traces
type Traces []Trace

type Frame struct {
Name string `json:"name"`
Data []Trace `json:"data"`
Layout interface{} `json:"layout"` //'Layout properties which this frame modifies. The format is identical to the normal layout definition.'
}

// Fig is the base type for figures.
type Fig struct {
// Data The data to be plotted is described in an array usually called data, whose elements are trace objects of various types (e.g. scatter, bar etc) as documented in the Full Reference.
Expand All @@ -34,6 +40,9 @@ type Fig struct {

// Animation is not yet implemented, feel free to insert custom a struct
Animation interface{} `json:"animation,omitempty"`

// Frames is not yet implemented, feel free to insert custom a struct
Frames []Frame `json:"frames,omitempty"`
}

// AddTraces Is a shorthand to add figures to a given figure. It handles the case where the Traces value is nil.
Expand All @@ -45,6 +54,7 @@ func (fig *Fig) AddTraces(traces ...Trace) {
}

// UnmarshalJSON is a custom unmarshal function to properly handle special cases.
// unmarshal skips frames and animations
func (fig *Fig) UnmarshalJSON(data []byte) error {
var err error
tmp := unmarshalFig{}
Expand All @@ -67,9 +77,11 @@ func (fig *Fig) UnmarshalJSON(data []byte) error {
}

type unmarshalFig struct {
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Data []json.RawMessage `json:"data,omitempty"`
Layout *Layout `json:"layout,omitempty"`
Config *Config `json:"config,omitempty"`
Animation interface{} `json:"animation,omitempty"`
Frames []Frame `json:"frames,omitempty"`
}

// Bool represents a *bool value. Needed to tell the differenc between false and nil.
Expand Down

0 comments on commit 1492cb7

Please sign in to comment.