Creating sunburst and sunburst segments as echarts format and test for instance creation.

This commit is contained in:
ruidajo 2022-09-22 09:07:56 -05:00
parent 07af684d34
commit 2bb7cf53ab
3 changed files with 60 additions and 0 deletions

View File

@ -7,6 +7,32 @@ Class {
#category : #'EchartsPharo-EchartsPharo'
}
{ #category : #accessing }
EcSunburst >> asEcScript [
^ 'var mySunburst = echarts.init(document.getElementById(','''', 'sunburst', '''', '));',
Character cr asString,
'var data = [',
']',
Character cr asString,
'var option = {
series: {
type:', '''', 'sunburst', '''', ',
data: data,
radius: [0, ', '''', '90%', '''', '],
label: {
rotate:', '''', 'tangential', '''', ',
fontSize: 15,
}
}
};
mySunburst.setOption(option);'
]
{ #category : #accessing }
EcSunburst >> segments [

View File

@ -21,6 +21,25 @@ EcSunburstSegment class >> name: aName value: aNumber color: aColor children: an
yourself
]
{ #category : #'instace creation' }
EcSunburstSegment class >> rootName: aString [
^ self new
name: aString;
value: 0;
yourself
]
{ #category : #accessing }
EcSunburstSegment >> asEcObjectString [
^ '{ name: ', name, ',
value: ', value asString, ',
color: ', '''', color asHTMLColor, '''', ',
children: []', Character cr asString,
'}'
]
{ #category : #accessing }
EcSunburstSegment >> children [
@ -45,6 +64,12 @@ EcSunburstSegment >> color: aColor [
color := aColor
]
{ #category : #accessing }
EcSunburstSegment >> isRoot [
^ value = 0
]
{ #category : #accessing }
EcSunburstSegment >> name [

View File

@ -4,6 +4,15 @@ Class {
#category : #'EchartsPharo-EchartsPharo'
}
{ #category : #accessing }
EcSunburstSegmentTest >> testSunburstSegmentRootCreation [
| sunburstSegment |
sunburstSegment := (EcSunburstSegment rootName: 'rootTest').
self assert: {sunburstSegment name. sunburstSegment isRoot} equals: {'rootTest'. true}
]
{ #category : #accessing }
EcSunburstSegmentTest >> testSunbusrtSegmentInstanceCreation [