Creating Baseline and Echarts Calendar.
This commit is contained in:
commit
5f0db70a84
3
Apps/.properties
Normal file
3
Apps/.properties
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
#format : #tonel
|
||||||
|
}
|
31
Apps/BaselineOfEchartsPharo/BaselineOfEchartsPharo.class.st
Normal file
31
Apps/BaselineOfEchartsPharo/BaselineOfEchartsPharo.class.st
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
Class {
|
||||||
|
#name : #BaselineOfEchartsPharo,
|
||||||
|
#superclass : #BaselineOf,
|
||||||
|
#category : #BaselineOfEchartsPharo
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #baseline }
|
||||||
|
BaselineOfEchartsPharo >> baseline: spec [
|
||||||
|
|
||||||
|
<baseline>
|
||||||
|
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
|
||||||
|
]
|
1
Apps/BaselineOfEchartsPharo/package.st
Normal file
1
Apps/BaselineOfEchartsPharo/package.st
Normal file
@ -0,0 +1 @@
|
|||||||
|
Package { #name : #BaselineOfEchartsPharo }
|
120
Apps/EchartsPharo/EcCalendar.class.st
Normal file
120
Apps/EchartsPharo/EcCalendar.class.st
Normal file
@ -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 [
|
||||||
|
|
||||||
|
^ '<div id="calendar" style="width:90vw;height:400px;"></div>', Character cr asString,
|
||||||
|
'<script type="text/javascript">', Character cr asString,
|
||||||
|
self asEcScript, Character cr asString,
|
||||||
|
'</script>'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #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), ']'
|
||||||
|
]
|
106
Apps/EchartsPharo/EcEvent.class.st
Normal file
106
Apps/EchartsPharo/EcEvent.class.st
Normal file
@ -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
|
||||||
|
]
|
1
Apps/EchartsPharo/package.st
Normal file
1
Apps/EchartsPharo/package.st
Normal file
@ -0,0 +1 @@
|
|||||||
|
Package { #name : #EchartsPharo }
|
Loading…
Reference in New Issue
Block a user