From 5f0db70a84d1ab7ac6646cd22419c399df901110 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Fri, 2 Sep 2022 00:00:10 +0000 Subject: [PATCH] Creating Baseline and Echarts Calendar. --- .project | 3 + Apps/.properties | 3 + .../BaselineOfEchartsPharo.class.st | 31 +++++ Apps/BaselineOfEchartsPharo/package.st | 1 + Apps/EchartsPharo/EcCalendar.class.st | 120 ++++++++++++++++++ Apps/EchartsPharo/EcEvent.class.st | 106 ++++++++++++++++ Apps/EchartsPharo/package.st | 1 + 7 files changed, 265 insertions(+) create mode 100644 .project create mode 100644 Apps/.properties create mode 100644 Apps/BaselineOfEchartsPharo/BaselineOfEchartsPharo.class.st create mode 100644 Apps/BaselineOfEchartsPharo/package.st create mode 100644 Apps/EchartsPharo/EcCalendar.class.st create mode 100644 Apps/EchartsPharo/EcEvent.class.st create mode 100644 Apps/EchartsPharo/package.st diff --git a/.project b/.project new file mode 100644 index 0000000..f02df3b --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory' : 'Apps' +} \ No newline at end of file diff --git a/Apps/.properties b/Apps/.properties new file mode 100644 index 0000000..ad0471d --- /dev/null +++ b/Apps/.properties @@ -0,0 +1,3 @@ +{ + #format : #tonel +} \ No newline at end of file diff --git a/Apps/BaselineOfEchartsPharo/BaselineOfEchartsPharo.class.st b/Apps/BaselineOfEchartsPharo/BaselineOfEchartsPharo.class.st new file mode 100644 index 0000000..66fadf9 --- /dev/null +++ b/Apps/BaselineOfEchartsPharo/BaselineOfEchartsPharo.class.st @@ -0,0 +1,31 @@ +Class { + #name : #BaselineOfEchartsPharo, + #superclass : #BaselineOf, + #category : #BaselineOfEchartsPharo +} + +{ #category : #baseline } +BaselineOfEchartsPharo >> baseline: spec [ + + + spec for: #'common' do: [ + "Dependencies" + self miniDocs: spec. + spec package: 'EchartsPharo' with: [ spec requires: #( 'MiniDocs' 'EchartsPharo' ) ] + ] +] + +{ #category : #accessing } +BaselineOfEchartsPharo >> miniDocs: spec [ + + | repo | + repo := ExoRepo new + repository: 'https://code.tupale.co/Offray/MiniDocs'. + repo load. + spec baseline: 'MiniDocs' with: [ spec repository: 'gitlocal://', repo local fullName ] +] + +{ #category : #accessing } +BaselineOfEchartsPharo >> projectClass [ + ^ MetacelloCypressBaselineProject +] diff --git a/Apps/BaselineOfEchartsPharo/package.st b/Apps/BaselineOfEchartsPharo/package.st new file mode 100644 index 0000000..dff94e3 --- /dev/null +++ b/Apps/BaselineOfEchartsPharo/package.st @@ -0,0 +1 @@ +Package { #name : #BaselineOfEchartsPharo } diff --git a/Apps/EchartsPharo/EcCalendar.class.st b/Apps/EchartsPharo/EcCalendar.class.st new file mode 100644 index 0000000..529d11e --- /dev/null +++ b/Apps/EchartsPharo/EcCalendar.class.st @@ -0,0 +1,120 @@ +Class { + #name : #EcCalendar, + #superclass : #Object, + #instVars : [ + 'events' + ], + #category : #EchartsPharo +} + +{ #category : #accessing } +EcCalendar >> asEcScript [ + + ^ 'var myCalendar = echarts.init(document.getElementById(',($' asString), 'calendar', ($' asString), '));', Character cr asString, + 'var option = { + tooltip: {}, + animation: true, + animationDuration: 500, + + legend: { + data:', self eventsLabel, ',', + 'left:', ($' asString ), '0',($' asString), + '}, + + calendar: { + top:', ($' asString), 'middle', ($' asString), ',', + 'left:', ($' asString),'0', ($' asString), ',', + 'orient:', ($' asString), 'horizontal', ($' asString), ',', + 'cellSize: 40, + yearLabel: { + margin: 50, + fontSize: 30, + color:', ($' asString), '#999', ($' asString), + '}, + dayLabel: { + firstDay: 1, + nameMap:', ($' asString), 'cn', ($' asString), + '}, + monthLabel: { + nameMap:', ($' asString),'cn', ($' asString), ',', + 'margin: 15, + fontSize: 20, + color:', ($' asString), '#999', ($' asString), + '}, + range:', self datesRangeWithMarginString, + '}, + + series: [', Character cr asString, + self eventsAsStringSnippets, + '] +}; +myCalendar.setOption(option);' +] + +{ #category : #accessing } +EcCalendar >> asHTMLElement [ + + ^ '
', Character cr asString, + '' +] + +{ #category : #accessing } +EcCalendar >> datesRange [ + + | tempEventsDates | + tempEventsDates := self events collect: [ :each | each dates ]. + tempEventsDates := tempEventsDates flattened collect: [ :each | each asDate ]. + ^ {tempEventsDates asSortedCollection first . + tempEventsDates asSortedCollection last }. +] + +{ #category : #accessing } +EcCalendar >> datesRangeString [ + + | datesRangeTemp | + datesRangeTemp := self datesRange collect: [ :date | ($' asString), date yyyymmdd, ($' asString) ]. + ^ '[', (',' join: datesRangeTemp), ']' +] + +{ #category : #accessing } +EcCalendar >> datesRangeWithMargin [ + + | tempEventsDates | + tempEventsDates := self events collect: [ :each | each dates ]. + tempEventsDates := tempEventsDates flattened collect: [ :each | each asDate ]. + ^ {(tempEventsDates asSortedCollection first asDateAndTime - 10 days) asDate . + (tempEventsDates asSortedCollection last) addDays: 10 }. +] + +{ #category : #accessing } +EcCalendar >> datesRangeWithMarginString [ + + | datesRangeTemp | + datesRangeTemp := self datesRangeWithMargin collect: [ :date | ($' asString), date yyyymmdd, ($' asString) ]. + ^ '[', (',' join: datesRangeTemp), ']' +] + +{ #category : #accessing } +EcCalendar >> events [ + ^ events ifNil: [ events := OrderedCollection new ]. +] + +{ #category : #accessing } +EcCalendar >> eventsAsStringSnippets [ + + | tempEvents | + tempEvents := self events. + tempEvents ifNil: [ ^ self ]. + ^ Character cr join: (tempEvents collect: [ :each | each asStringSnippet ]) +] + +{ #category : #accessing } +EcCalendar >> eventsLabel [ + + | tempEvents | + tempEvents := self events collect: [ :each | each name ]. + tempEvents := tempEvents collect: [ :each | ($' asString), each, ($' asString) ]. + ^ '[', (',' join: tempEvents), ']' +] diff --git a/Apps/EchartsPharo/EcEvent.class.st b/Apps/EchartsPharo/EcEvent.class.st new file mode 100644 index 0000000..5a35912 --- /dev/null +++ b/Apps/EchartsPharo/EcEvent.class.st @@ -0,0 +1,106 @@ +Class { + #name : #EcEvent, + #superclass : #Object, + #instVars : [ + 'dates', + 'color', + 'type', + 'name', + 'label' + ], + #category : #EchartsPharo +} + +{ #category : #accessing } +EcEvent >> asStringSnippet [ + + ^ '{ type:', ($' asString), self type,($' asString), ', + name:', ($' asString), self name,($' asString), ', + edgeSymbol: [',($' asString),'none',($' asString),',',($' asString),'arrow',($' asString),'], + coordinateSystem:',($' asString),'calendar',($' asString),', + symbolSize: 15, + itemStyle: { + color:', ($' asString),'#',self color asHexString,($' asString),', + shadowBlur: 9, + shadowOffsetX: 1.5, + shadowOffsetY: 3, + shadowColor:',($' asString),'#555',($' asString), + '}, + data:', self datesAsString, ', + z: 3 +},' +] + +{ #category : #accessing } +EcEvent >> color [ + + ^ color +] + +{ #category : #accessing } +EcEvent >> color: anObject [ + + color := anObject +] + +{ #category : #accessing } +EcEvent >> dates [ + + ^ dates +] + +{ #category : #accessing } +EcEvent >> dates: anObject [ + + dates := anObject +] + +{ #category : #accessing } +EcEvent >> datesAsString [ + + | tempDates datesCount | + tempDates := self dates. + tempDates ifNil: [ ^ self ]. + tempDates := tempDates collect: [ :each | each asDate ]. + tempDates := tempDates collect: [ :date | + '[', ($' asString), date asDate yyyymmdd,($' asString) ]. + datesCount := OrderedCollection new. + tempDates doWithIndex: [ :date :i | datesCount add: (date, ',', (i asString), ']') ]. + ^ '[', (',' join: datesCount ), ']' +] + +{ #category : #accessing } +EcEvent >> label [ + + ^ label +] + +{ #category : #accessing } +EcEvent >> label: anObject [ + + label := anObject +] + +{ #category : #accessing } +EcEvent >> name [ + + ^ name +] + +{ #category : #accessing } +EcEvent >> name: anObject [ + + name := anObject +] + +{ #category : #accessing } +EcEvent >> type [ + + ^ type +] + +{ #category : #accessing } +EcEvent >> type: anObject [ + + type := anObject +] diff --git a/Apps/EchartsPharo/package.st b/Apps/EchartsPharo/package.st new file mode 100644 index 0000000..0db9168 --- /dev/null +++ b/Apps/EchartsPharo/package.st @@ -0,0 +1 @@ +Package { #name : #EchartsPharo }