diff --git a/src/Seaside-Plotly-Core/PlotlyLine.class.st b/src/Seaside-Plotly-Core/PlotlyLine.class.st index ab2b469..f6bd587 100644 --- a/src/Seaside-Plotly-Core/PlotlyLine.class.st +++ b/src/Seaside-Plotly-Core/PlotlyLine.class.st @@ -11,9 +11,41 @@ PlotlyLine class >> spline [ yourself ] +{ #category : #accessing } +PlotlyLine >> color: aColor [ + + "set the color of the line" + + self propertyAt: 'color' put: aColor +] + +{ #category : #accessing } +PlotlyLine >> dash: aString [ + + "aString can be: solid, dot, dash, longdash, dashdot, or longdashdot" + + self propertyAt: 'dash' put: aString +] + { #category : #accessing } PlotlyLine >> shape: aString [ "aString can be: linear, spline, vhv, hvh, vhv, hv, vh" self propertyAt: 'shape' put: aString ] + +{ #category : #accessing } +PlotlyLine >> smoothing: aNumber [ + + "aNumber can be between 0 and 1.3. Is only used when the line shape is set to 'spline'" + + self propertyAt: 'smoothing' put: aNumber +] + +{ #category : #accessing } +PlotlyLine >> width: aNumber [ + + "The width of the line. aNumber can be greater than or equal to 0." + + self propertyAt: 'width' put: aNumber +] diff --git a/src/Seaside-Plotly-Core/PlotlyTrace.class.st b/src/Seaside-Plotly-Core/PlotlyTrace.class.st index 0611291..b86f817 100644 --- a/src/Seaside-Plotly-Core/PlotlyTrace.class.st +++ b/src/Seaside-Plotly-Core/PlotlyTrace.class.st @@ -71,6 +71,18 @@ PlotlyTrace >> dontClipOnAxis [ self clipOnAxis: false ] +{ #category : #configuring } +PlotlyTrace >> line [ + + ^ self propertyAt: 'line' ifAbsentPut: [ PlotlyLine new ] +] + +{ #category : #configuring } +PlotlyTrace >> line: aPlotlyLine [ + + self propertyAt: 'line' put: aPlotlyLine +] + { #category : #convenience } PlotlyTrace >> lineAndMarkersMode [ diff --git a/src/Seaside-Plotly-Examples/WAPlotlyExamples.class.st b/src/Seaside-Plotly-Examples/WAPlotlyExamples.class.st index 40fc215..fe32fe1 100644 --- a/src/Seaside-Plotly-Examples/WAPlotlyExamples.class.st +++ b/src/Seaside-Plotly-Examples/WAPlotlyExamples.class.st @@ -13,9 +13,12 @@ WAPlotlyExamples class >> initialize [ { #category : #'rendering-meta' } WAPlotlyExamples >> examples [ - ^ OrderedCollection streamContents: [ :s | - (Pragma allNamed: #example in: self class) do: [ :pragma | - s nextPut: pragma method selector ] ] + ^ OrderedCollection + streamContents: [ :s | + (Pragma + allNamed: #example in: self class) + do: [ :pragma | s nextPut: pragma method selector ] ] + ] { #category : #private } @@ -257,6 +260,39 @@ WAPlotlyExamples >> scriptExampleHistogramOn: script elementId: elementId [ script << plotly ] +{ #category : #'javascript-examples' } +WAPlotlyExamples >> scriptExampleLineTypeOn: script elementId: elementId [ + + + | plotly | + plotly := script plotly: elementId. + plotly + data: { + (PlotlyTrace scatter + name: 'Spline series'; + showlegend: true; + line: (PlotlyLine new + shape: 'spline'; + color: Color lightGray; + dash: 'dot'; + yourself); + x: (1 to: 10) asArray; + y: ((1 to: 10) collect: [ :each | 10 atRandom / 2 ]); + yourself). "Color veryLightGray" + (PlotlyTrace scatter + name: 'Linear series'; + showlegend: true; + x: (1 to: 10) asArray; + y: ((1 to: 10) collect: [ :each | 10 atRandom / 2 ]); + yourself) }; + layout: (PlotlyLayout new + title: (PlotlyText text: 'Line Types'); + width: 500 height: 300; + yourself). + plotly config beResponsive. + script << plotly +] + { #category : #'javascript-examples' } WAPlotlyExamples >> scriptExamplePieInstantationOn: script elementId: elementId [