-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feenkcom/gtoolkit#3775] added examples for vertical and horizontal b…
…ar lines
- Loading branch information
Showing
10 changed files
with
361 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Class { | ||
#name : #GtPlotterBarChartElement, | ||
#superclass : #BlElement, | ||
#instVars : [ | ||
'tickLabels', | ||
'bars', | ||
'lines' | ||
], | ||
#category : #'GToolkit-Plotter-Builder - Bar Chart' | ||
} | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarChartElement >> barsElement [ | ||
<return: #BlElement> | ||
^ bars | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarChartElement >> barsElement: anBlElement [ | ||
bars := anBlElement. | ||
self addChild: bars | ||
] | ||
|
||
{ #category : #initialization } | ||
GtPlotterBarChartElement >> initialize [ | ||
super initialize. | ||
self | ||
clipChildren: false; | ||
padding: (BlInsets all: 10); | ||
constraintsDo: [ :c | | ||
c horizontal matchParent. | ||
c vertical matchParent ]. | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarChartElement >> lines [ | ||
<return: #OrderedCollection> | ||
^ lines | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarChartElement >> lines: aCollectionOfLineElements [ | ||
lines := aCollectionOfLineElements. | ||
self addChildren: lines. | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarChartElement >> tickLabelsElement [ | ||
<return: #GtPlotterTickLabelsElement> | ||
^ tickLabels | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarChartElement >> tickLabelsElement: aGtPlotterTickLabelsElement [ | ||
tickLabels := aGtPlotterTickLabelsElement. | ||
self addChild: tickLabels. | ||
] |
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,44 @@ | ||
Class { | ||
#name : #GtPlotterBarLineExamples, | ||
#superclass : #Object, | ||
#category : #'GToolkit-Plotter-Example - Bar Lines' | ||
} | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarLineExamples >> barChartLineStyle [ | ||
| barChart border chartElement | | ||
barChart := self thresholdChartScrollableContentsAddsOneLine. | ||
border := BlBorderBuilder new | ||
paint: Color blue; | ||
dashed; | ||
capRound; | ||
width: 2; | ||
build. | ||
barChart lines first | ||
lineStencil: [ BlLineElement new border: border ]. | ||
chartElement := self createChartElement: barChart. | ||
self assert: chartElement lines first border equals: border. | ||
^ chartElement | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarLineExamples >> barChartScalableContents [ | ||
| barChart | | ||
barChart := self thresholdChartScrollableContentsAddsOneLine. | ||
barChart scalableContents. | ||
^ barChart | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarLineExamples >> createChartElement: barChart [ | ||
| chartElement | | ||
chartElement := barChart create. | ||
chartElement size: 300 asPoint. | ||
chartElement forceLayout. | ||
^ chartElement. | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterBarLineExamples >> thresholdChartScrollableContentsAddsOneLine [ | ||
^ self subclassResponsibility | ||
] |
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
93 changes: 93 additions & 0 deletions
93
src/GToolkit-Plotter/GtPlotterHorizontalLineExamples.class.st
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,93 @@ | ||
" | ||
GtPlotterVerticalBarChart utilizes rectangles to represent bars. However, the chart also has the capability to generate horizontal lines for displaying minimum, maximum, average, and threshold values. To create a horizontal line instance for such purposes, utilize the method `chart newHorizontalLine`, which generates and returns a new instance of GtPlotterHorizontalLine. | ||
" | ||
Class { | ||
#name : #GtPlotterHorizontalLineExamples, | ||
#superclass : #GtPlotterBarLineExamples, | ||
#category : #'GToolkit-Plotter-Example - Bar Lines' | ||
} | ||
|
||
{ #category : #examples } | ||
GtPlotterHorizontalLineExamples >> barChartForNumbers [ | ||
<gtExample> | ||
| barChart | | ||
barChart := GtPlotterVerticalBarChart newFromValues: #(8 10 15 9 12). | ||
self assert: barChart lines size = 0. | ||
^ barChart | ||
] | ||
|
||
{ #category : #examples } | ||
GtPlotterHorizontalLineExamples >> barChartLineStyle [ | ||
<gtExample> | ||
^ super barChartLineStyle | ||
] | ||
|
||
{ #category : #examples } | ||
GtPlotterHorizontalLineExamples >> barChartScalableContentsPercentMax [ | ||
<gtExample> | ||
| barChart chartElement max | | ||
barChart := self barChartScalableContents. | ||
max := 0.5. | ||
barChart lines first | ||
min: 0; | ||
max: max. | ||
chartElement := self createChartElement: barChart. | ||
self assert: chartElement lines isNotEmpty. | ||
self | ||
assert: chartElement lines first width | ||
equals: chartElement barsElement width * max. | ||
^ chartElement | ||
] | ||
|
||
{ #category : #examples } | ||
GtPlotterHorizontalLineExamples >> barChartScalableContentsPercentMin [ | ||
<gtExample> | ||
| barChart chartElement min | | ||
barChart := self barChartScalableContents. | ||
min := 0.5. | ||
barChart lines first | ||
min: min; | ||
max: 1. | ||
chartElement := self createChartElement: barChart. | ||
self assert: chartElement lines isNotEmpty. | ||
self | ||
assert: chartElement lines first width | ||
equals: chartElement barsElement width * min. | ||
^ chartElement | ||
] | ||
|
||
{ #category : #examples } | ||
GtPlotterHorizontalLineExamples >> barChartScalableContentsShouldExpandLine [ | ||
<gtExample> | ||
| barChart chartElement | | ||
barChart := self barChartScalableContents. | ||
chartElement := self createChartElement: barChart. | ||
self assert: chartElement lines isNotEmpty. | ||
self | ||
assert: chartElement lines first width | ||
equals: chartElement barsElement width. | ||
^ chartElement | ||
] | ||
|
||
{ #category : #accessing } | ||
GtPlotterHorizontalLineExamples >> barChartScrollabelContentsShouldNotPassBarsExtent [ | ||
<gtExample> | ||
| barChart barElement width | | ||
barChart := self thresholdChartScrollableContentsAddsOneLine. | ||
barElement := self createChartElement: barChart. | ||
width := barElement lines first width. | ||
self assert: width < barElement width. | ||
^ barElement | ||
] | ||
|
||
{ #category : #examples } | ||
GtPlotterHorizontalLineExamples >> thresholdChartScrollableContentsAddsOneLine [ | ||
<gtExample> | ||
| barChart threshold | | ||
barChart := self barChartForNumbers. | ||
threshold := 10. | ||
barChart newHorizontalLine dataValue: threshold. | ||
self assert: barChart lines size equals: 1. | ||
^ barChart | ||
] |
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.