@operato/scene-chartjs 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +21 -0
  4. package/assets/bar-chart.png +0 -0
  5. package/assets/doughnut-chart.png +0 -0
  6. package/assets/horizontal-bar-chart.png +0 -0
  7. package/assets/line-chart.png +0 -0
  8. package/assets/mixed-chart.png +0 -0
  9. package/assets/pie-chart.png +0 -0
  10. package/assets/polar-area-chart.png +0 -0
  11. package/assets/radar-chart.png +0 -0
  12. package/demo/bar.html +266 -0
  13. package/demo/chartjs.html +73 -0
  14. package/demo/index.html +547 -0
  15. package/demo/legend.html +267 -0
  16. package/demo/things-scene-chartjs.html +7 -0
  17. package/dist/chartjs.d.ts +27 -0
  18. package/dist/chartjs.js +109 -0
  19. package/dist/chartjs.js.map +1 -0
  20. package/dist/config-converter.d.ts +1 -0
  21. package/dist/config-converter.js +343 -0
  22. package/dist/config-converter.js.map +1 -0
  23. package/dist/editors/index.d.ts +5 -0
  24. package/dist/editors/index.js +11 -0
  25. package/dist/editors/index.js.map +1 -0
  26. package/dist/editors/property-editor-chartjs-abstract.d.ts +44 -0
  27. package/dist/editors/property-editor-chartjs-abstract.js +250 -0
  28. package/dist/editors/property-editor-chartjs-abstract.js.map +1 -0
  29. package/dist/editors/property-editor-chartjs-hbar.d.ts +9 -0
  30. package/dist/editors/property-editor-chartjs-hbar.js +160 -0
  31. package/dist/editors/property-editor-chartjs-hbar.js.map +1 -0
  32. package/dist/editors/property-editor-chartjs-mixed.d.ts +20 -0
  33. package/dist/editors/property-editor-chartjs-mixed.js +193 -0
  34. package/dist/editors/property-editor-chartjs-mixed.js.map +1 -0
  35. package/dist/editors/property-editor-chartjs-multi-series-abstract.d.ts +31 -0
  36. package/dist/editors/property-editor-chartjs-multi-series-abstract.js +373 -0
  37. package/dist/editors/property-editor-chartjs-multi-series-abstract.js.map +1 -0
  38. package/dist/editors/property-editor-chartjs-pie.d.ts +14 -0
  39. package/dist/editors/property-editor-chartjs-pie.js +70 -0
  40. package/dist/editors/property-editor-chartjs-pie.js.map +1 -0
  41. package/dist/editors/property-editor-chartjs-radar.d.ts +10 -0
  42. package/dist/editors/property-editor-chartjs-radar.js +42 -0
  43. package/dist/editors/property-editor-chartjs-radar.js.map +1 -0
  44. package/dist/editors/property-editor-chartjs-styles.d.ts +1 -0
  45. package/dist/editors/property-editor-chartjs-styles.js +165 -0
  46. package/dist/editors/property-editor-chartjs-styles.js.map +1 -0
  47. package/dist/editors/property-editor-chartjs.d.ts +14 -0
  48. package/dist/editors/property-editor-chartjs.js +83 -0
  49. package/dist/editors/property-editor-chartjs.js.map +1 -0
  50. package/dist/index.d.ts +5 -0
  51. package/dist/index.js +8 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/ox-chart.d.ts +20 -0
  54. package/dist/ox-chart.js +137 -0
  55. package/dist/ox-chart.js.map +1 -0
  56. package/dist/plugins/chart-series-highlight.d.ts +5 -0
  57. package/dist/plugins/chart-series-highlight.js +37 -0
  58. package/dist/plugins/chart-series-highlight.js.map +1 -0
  59. package/dist/plugins/chartjs-plugin-data-binder.d.ts +5 -0
  60. package/dist/plugins/chartjs-plugin-data-binder.js +111 -0
  61. package/dist/plugins/chartjs-plugin-data-binder.js.map +1 -0
  62. package/helps/scene/component/chartjs.ko.md +332 -0
  63. package/helps/scene/component/chartjs.md +333 -0
  64. package/helps/scene/component/chartjs.zh.md +331 -0
  65. package/helps/scene/images/chart-bar-01.png +0 -0
  66. package/helps/scene/images/chart-bar-02.png +0 -0
  67. package/helps/scene/images/chart-bar-03.png +0 -0
  68. package/helps/scene/images/chart-bar-08.png +0 -0
  69. package/helps/scene/images/chart-bar-12.png +0 -0
  70. package/helps/scene/images/chart-data-01.png +0 -0
  71. package/helps/scene/images/chart-data-04.png +0 -0
  72. package/helps/scene/images/chart-doughnut-01.png +0 -0
  73. package/helps/scene/images/chart-horizontal-bar-01.png +0 -0
  74. package/helps/scene/images/chart-line-01.png +0 -0
  75. package/helps/scene/images/chart-mix-01.png +0 -0
  76. package/helps/scene/images/chart-mix-02.png +0 -0
  77. package/helps/scene/images/chart-pie-01.png +0 -0
  78. package/helps/scene/images/chart-polar-01.png +0 -0
  79. package/helps/scene/images/chart-radar-01.png +0 -0
  80. package/package.json +78 -0
  81. package/src/chartjs.ts +134 -0
  82. package/src/config-converter.ts +401 -0
  83. package/src/editors/index.ts +11 -0
  84. package/src/editors/property-editor-chartjs-abstract.ts +301 -0
  85. package/src/editors/property-editor-chartjs-hbar.ts +163 -0
  86. package/src/editors/property-editor-chartjs-mixed.ts +204 -0
  87. package/src/editors/property-editor-chartjs-multi-series-abstract.ts +393 -0
  88. package/src/editors/property-editor-chartjs-pie.ts +79 -0
  89. package/src/editors/property-editor-chartjs-radar.ts +43 -0
  90. package/src/editors/property-editor-chartjs-styles.ts +165 -0
  91. package/src/editors/property-editor-chartjs.ts +88 -0
  92. package/src/index.ts +7 -0
  93. package/src/ox-chart.ts +150 -0
  94. package/src/plugins/chart-series-highlight.ts +43 -0
  95. package/src/plugins/chartjs-plugin-data-binder.ts +138 -0
  96. package/src/scene-chart.d.ts +152 -0
  97. package/templates/bar-chart.js +124 -0
  98. package/templates/doughnut-chart.js +58 -0
  99. package/templates/horizontal-bar-chart.js +121 -0
  100. package/templates/index.js +22 -0
  101. package/templates/line-chart.js +155 -0
  102. package/templates/mixed-chart.js +152 -0
  103. package/templates/pie-chart.js +58 -0
  104. package/templates/polar-area-chart.js +92 -0
  105. package/templates/radar-chart.js +98 -0
  106. package/test/basic-test.html +61 -0
  107. package/test/index.html +20 -0
  108. package/things-scene.config.js +7 -0
  109. package/translations/en.json +5 -0
  110. package/translations/ko.json +5 -0
  111. package/translations/ms.json +5 -0
  112. package/translations/zh.json +5 -0
  113. package/tsconfig.json +22 -0
  114. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,163 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@polymer/iron-icon/iron-icon'
5
+ import '@polymer/paper-button/paper-button'
6
+ import '@polymer/paper-icon-button/paper-icon-button'
7
+ import '@polymer/paper-tabs/paper-tabs'
8
+
9
+ import { html } from 'lit'
10
+ import { customElement } from 'lit/decorators.js'
11
+
12
+ import PropertyEditorChartJSMultiSeriesAbstract from './property-editor-chartjs-multi-series-abstract'
13
+
14
+ @customElement('property-editor-chartjs-hbar')
15
+ export default class PropertyEditorChartJSHBar extends PropertyEditorChartJSMultiSeriesAbstract {
16
+ editorTemplate() {
17
+ return html`
18
+ <legend><i18n-msg msgid="label.series">Series</i18n-msg></legend>
19
+ ${this.multiSeriesTabTemplate()}
20
+
21
+ <legend><i18n-msg msgid="label.y-axes">Y Axes</i18n-msg></legend>
22
+
23
+ <label> <i18n-msg msgid="label.data-key">Data Key</i18n-msg> </label>
24
+ <input type="text" value-key="labelDataKey" .value=${this.labelDataKey} />
25
+
26
+ <label> <i18n-msg msgid="label.title">Title</i18n-msg> </label>
27
+ <input type="text" value-key="yAxes0.axisTitle" .value=${this.yAxes0.axisTitle || ''} />
28
+
29
+ <label><i18n-msg msgid="label.bar-spacing">Bar Spacing</i18n-msg></label>
30
+ <input
31
+ type="number"
32
+ min="0"
33
+ max="1"
34
+ step="0.1"
35
+ value-key="yAxes0.barSpacing"
36
+ .value=${this.yAxes0.barSpacing || NaN}
37
+ />
38
+ <label><i18n-msg msgid="label.tick-spacing">Tick Spacing</i18n-msg></label>
39
+ <input
40
+ type="number"
41
+ min="0"
42
+ max="1"
43
+ step="0.1"
44
+ value-key="yAxes0.categorySpacing"
45
+ .value=${this.yAxes0.categorySpacing || NaN}
46
+ />
47
+
48
+ <input type="checkbox" value-key="value.options.xGridLine" .checked=${this.value.options.xGridLine} />
49
+ <label> <i18n-msg msgid="label.grid-line">Grid Line</i18n-msg> </label>
50
+
51
+ <input type="checkbox" value-key="xAxes0.ticks.display" .checked=${this.xAxes0.ticks.display} />
52
+ <label> <i18n-msg msgid="label.display-tick">Display Tick</i18n-msg> </label>
53
+
54
+ <legend><i18n-msg msgid="label.x-axes">X Axes</i18n-msg></legend>
55
+
56
+ <label> <i18n-msg msgid="label.title">Title</i18n-msg> </label>
57
+ <input type="text" value-key="xAxes0.title" .value=${this.xAxes0.axisTitle || ''} />
58
+
59
+ <input type="checkbox" value-key="xAxes0.ticks.autoMin" .checked=${this.xAxes0.ticks.autoMin} />
60
+ <label> <i18n-msg msgid="label.axis-min-auto">Axis Min Auto</i18n-msg> </label>
61
+
62
+ <input type="checkbox" value-key="xAxes0.ticks.autoMax" .checked=${this.xAxes0.ticks.autoMax} />
63
+ <label> <i18n-msg msgid="label.axis-max-auto">Axis Max Auto</i18n-msg> </label>
64
+
65
+ ${!this.xAxes0.ticks.autoMin
66
+ ? html`
67
+ <label> <i18n-msg msgid="label.axis-min">Axis Min</i18n-msg> </label>
68
+ <input type="number" value-key="xAxes0.ticks.min" .value=${this.xAxes0.ticks.min} />
69
+ `
70
+ : html``}
71
+ ${!this.xAxes0.ticks.autoMax
72
+ ? html`
73
+ <label> <i18n-msg msgid="label.axis-max">Axis Max</i18n-msg> </label>
74
+ <input type="number" value-key="xAxes0.ticks.max" .value=${this.xAxes0.ticks.max} />
75
+ `
76
+ : html``}
77
+
78
+ <label> <i18n-msg msgid="label.axis-step-size">Axis Step Size</i18n-msg> </label>
79
+ <input type="number" value-key="yAxes0.ticks.stepSize" .value=${this.yAxes0.ticks.stepSize} />
80
+
81
+ <input type="checkbox" .checked=${this.value.options.yGridLine} />
82
+ <label> <i18n-msg msgid="label.grid-line">Grid Line</i18n-msg> </label>
83
+
84
+ <input type="checkbox" value-key="yAxes0.ticks.display" .checked=${this.yAxes0.ticks.display} />
85
+ <label> <i18n-msg msgid="label.display-tick">Display Tick</i18n-msg> </label>
86
+ `
87
+ }
88
+
89
+ multiSeriesTabTemplate() {
90
+ return html`
91
+ <div id="series-properties-container" fullwidth>
92
+ <div id="tab-header">
93
+ <paper-icon-button
94
+ id="tab-nav-left-button"
95
+ icon="chevron-left"
96
+ @click=${(e: Event) => {
97
+ this._onTabScrollNavLeft(e)
98
+ }}
99
+ disabled
100
+ ></paper-icon-button>
101
+ <paper-tabs
102
+ id="tabs"
103
+ @iron-select=${(e: Event) => (this.currentSeriesIndex = (e.target as any).selected)}
104
+ .selected=${this.currentSeriesIndex}
105
+ no-bar
106
+ noink
107
+ scrollable
108
+ hide-scroll-buttons
109
+ fit-container
110
+ >
111
+ ${this.datasets.map(
112
+ (dataset: any, index: number) => html`
113
+ <paper-tab data-series="${index + 1}" noink
114
+ >${index + 1}
115
+ ${!this.datasets || (this.datasets.length != 1 && this.currentSeriesIndex == index)
116
+ ? html`
117
+ <paper-icon-button icon="close" @tap="${(e: Event) => this.onTapRemoveCurrentTab(e)}">
118
+ </paper-icon-button>
119
+ `
120
+ : html``}
121
+ </paper-tab>
122
+ `
123
+ )}
124
+ </paper-tabs>
125
+ <paper-icon-button
126
+ id="tab-nav-right-button"
127
+ icon="chevron-right"
128
+ @click=${(e: Event) => {
129
+ this._onTabScrollNavRight(e)
130
+ }}
131
+ disabled
132
+ ></paper-icon-button>
133
+ </div>
134
+ <div id="add-series-button-container">
135
+ <paper-icon-button
136
+ id="add-series-button"
137
+ icon="add"
138
+ @tap=${(e: Event) => this.onTapAddTab(e)}
139
+ ></paper-icon-button>
140
+ </div>
141
+
142
+ <iron-pages .selected=${this.currentSeriesIndex} .attr-for-selected="series-index">
143
+ ${this.datasets.map(
144
+ (dataset: any, index: number) => html`
145
+ <div class="tab-content" series-index="${index}">
146
+ <label> <i18n-msg msgid="label.data-key">Data Key</i18n-msg> </label>
147
+ <input type="text" value-key="dataKey" .value=${this.dataKey} />
148
+ <label> <i18n-msg msgid="label.label">Label</i18n-msg> </label>
149
+ <input type="text" value-key="series.label" .value=${this.series.label} />
150
+ <label> <i18n-msg msgid="label.color">Color</i18n-msg> </label>
151
+ <things-editor-color value-key="color" .value=${this.color}></things-editor-color>
152
+ <label> <i18n-msg msgid="label.stack-group">Stack Group</i18n-msg> </label>
153
+ <input type="text" value-key="series.stack" .value=${this.series.stack || ''} />
154
+
155
+ ${this.displayValueTemplate()}
156
+ </div>
157
+ `
158
+ )}
159
+ </iron-pages>
160
+ </div>
161
+ `
162
+ }
163
+ }
@@ -0,0 +1,204 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@polymer/iron-icon/iron-icon'
5
+ import '@polymer/iron-pages/iron-pages'
6
+ import '@polymer/paper-button/paper-button'
7
+ import '@polymer/paper-icon-button/paper-icon-button'
8
+ import '@polymer/paper-tabs/paper-tabs'
9
+
10
+ import { html } from 'lit'
11
+ import { customElement } from 'lit/decorators.js'
12
+
13
+ import PropertyEditorChartJSMultiSeriesAbstract from './property-editor-chartjs-multi-series-abstract'
14
+
15
+ @customElement('property-editor-chartjs-mixed')
16
+ export default class PropertyEditorChartJSMixed extends PropertyEditorChartJSMultiSeriesAbstract {
17
+ static styles = PropertyEditorChartJSMultiSeriesAbstract.styles
18
+
19
+ constructor() {
20
+ super()
21
+
22
+ this.value = {
23
+ options: {
24
+ legend: {},
25
+ scales: {
26
+ xAxes: [
27
+ {
28
+ ticks: {}
29
+ }
30
+ ],
31
+ yAxes: [
32
+ {
33
+ ticks: {}
34
+ }
35
+ ]
36
+ }
37
+ },
38
+ data: {
39
+ datasets: []
40
+ }
41
+ }
42
+ }
43
+
44
+ get xAxes0() {
45
+ return this.scales.xAxes[0]
46
+ }
47
+
48
+ set xAxes0(xAxes0) {
49
+ this.scales.xAxes[0] = xAxes0
50
+ }
51
+
52
+ get yAxes0() {
53
+ return this.scales.yAxes[0]
54
+ }
55
+
56
+ set yAxes0(yAxes0) {
57
+ this.scales.yAxes[0] = yAxes0
58
+ }
59
+
60
+ get yAxes1() {
61
+ return this.scales.yAxes[1]
62
+ }
63
+
64
+ set yAxes1(yAxes1) {
65
+ this.scales.yAxes[1] = yAxes1
66
+ }
67
+
68
+ get multiAxis() {
69
+ return this.value.options.multiAxis
70
+ }
71
+
72
+ set multiAxis(multiAxis) {
73
+ this.value.options.multiAxis = multiAxis
74
+ }
75
+
76
+ editorTemplate(props: any) {
77
+ return html`
78
+ <input type="checkbox" value-key="multiAxis" .checked=${this.multiAxis} />
79
+ <label> <i18n-msg msgid="label.multi-axis">Multi Axis</i18n-msg> </label>
80
+
81
+ <legend><i18n-msg msgid="label.series">Series</i18n-msg></legend>
82
+
83
+ <div fullwidth>${this.multiSeriesTabTemplate()}</div>
84
+
85
+ <legend><i18n-msg msgid="label.x-axes">X Axes</i18n-msg></legend>
86
+
87
+ <label> <i18n-msg msgid="label.data-key">Data Key</i18n-msg> </label>
88
+ <input type="text" value-key="labelDataKey" .value=${this.labelDataKey} />
89
+
90
+ <label> <i18n-msg msgid="label.title">Title</i18n-msg> </label>
91
+ <input type="text" value-key="xAxes0.axisTitle" .value=${this.xAxes0.axisTitle || ''} />
92
+
93
+ ${this._hasBarSeries(this.value)
94
+ ? html`
95
+ <label><i18n-msg msgid="label.bar-spacing">Bar Spacing</i18n-msg></label>
96
+ <input
97
+ type="number"
98
+ min="0"
99
+ max="1"
100
+ step="0.1"
101
+ value-key="xAxes0.barSpacing"
102
+ .value=${this.xAxes0.barSpacing || NaN}
103
+ />
104
+ <label><i18n-msg msgid="label.tick-spacing">Tick Spacing</i18n-msg></label>
105
+ <input
106
+ type="number"
107
+ min="0"
108
+ max="1"
109
+ step="0.1"
110
+ value-key="xAxes0.categorySpacing"
111
+ .value=${this.xAxes0.categorySpacing || NaN}
112
+ />
113
+ `
114
+ : html``}
115
+
116
+ <input type="checkbox" value-key="value.options.xGridLine" .checked=${props.value.options.xGridLine} />
117
+ <label> <i18n-msg msgid="label.grid-line">Grid Line</i18n-msg> </label>
118
+
119
+ <input type="checkbox" value-key="xAxes0.ticks.display" .checked=${this.xAxes0.ticks.display} />
120
+ <label> <i18n-msg msgid="label.display-tick">Display Tick</i18n-msg> </label>
121
+
122
+ <legend><i18n-msg msgid="label.y-axes">Y Axes</i18n-msg></legend>
123
+
124
+ <label> <i18n-msg msgid="label.title">Title</i18n-msg> </label>
125
+ <input type="text" value-key="yAxes0.axisTitle" .value=${this.yAxes0.axisTitle || ''} />
126
+
127
+ <input type="checkbox" value-key="yAxes0.ticks.autoMin" .checked=${this.yAxes0.ticks.autoMin} />
128
+ <label> <i18n-msg msgid="label.axis-min-auto">Min Auto</i18n-msg> </label>
129
+
130
+ <input type="checkbox" value-key="yAxes0.ticks.autoMax" .checked=${this.yAxes0.ticks.autoMax} />
131
+ <label> <i18n-msg msgid="label.axis-max-auto">Max Auto</i18n-msg> </label>
132
+
133
+ ${!this.yAxes0.ticks.autoMin
134
+ ? html`
135
+ <label> <i18n-msg msgid="label.axis-min">Min</i18n-msg> </label>
136
+ <input type="number" value-key="yAxes0.ticks.min" .value=${this.yAxes0.ticks.min} />
137
+ `
138
+ : html``}
139
+ ${!this.yAxes0.ticks.autoMax
140
+ ? html`
141
+ <label> <i18n-msg msgid="label.axis-max">Max</i18n-msg> </label>
142
+ <input type="number" value-key="yAxes0.ticks.max" .value=${this.yAxes0.ticks.max} />
143
+ `
144
+ : html``}
145
+
146
+ <label> <i18n-msg msgid="label.axis-step-size">StepSize</i18n-msg> </label>
147
+ <input type="number" value-key="yAxes0.ticks.stepSize" .value=${this.yAxes0.ticks.stepSize} />
148
+
149
+ <input type="checkbox" value-key="value.options.yGridLine" .checked=${props.value.options.yGridLine} />
150
+ <label> <i18n-msg msgid="label.grid-line">Grid Line</i18n-msg> </label>
151
+
152
+ <input type="checkbox" value-key="yAxes0.ticks.display" .checked=${this.yAxes0.ticks.display} />
153
+ <label> <i18n-msg msgid="label.display-tick">Display Tick</i18n-msg> </label>
154
+
155
+ ${props.value.options.multiAxis
156
+ ? html`
157
+ <legend><i18n-msg msgid="label.y-2nd-axes">Y 2nd Axes</i18n-msg></legend>
158
+
159
+ <label> <i18n-msg msgid="label.title">Title</i18n-msg> </label>
160
+ <input type="text" value-key="yAxes1.axisTitle" .value=${this.yAxes1.axisTitle || ''} />
161
+
162
+ <input type="checkbox" value-key="yAxes1.ticks.autoMin" .checked=${this.yAxes1.ticks.autoMin} />
163
+ <label> <i18n-msg msgid="label.axis-min-auto">Min Auto</i18n-msg> </label>
164
+
165
+ <input type="checkbox" value-key="yAxes1.ticks.autoMax" .checked=${this.yAxes1.ticks.autoMax} />
166
+ <label> <i18n-msg msgid="label.axis-max-auto">Max Auto</i18n-msg> </label>
167
+
168
+ ${!this.yAxes1.ticks.autoMin
169
+ ? html`
170
+ <label> <i18n-msg msgid="label.axis-min">Min</i18n-msg> </label>
171
+ <input type="number" value-key="yAxes1.ticks.min" .value=${this.yAxes1.ticks.min} />
172
+ `
173
+ : html``}
174
+ ${!this.yAxes1.ticks.autoMax
175
+ ? html`
176
+ <label> <i18n-msg msgid="label.axis-max">Max</i18n-msg> </label>
177
+ <input type="number" value-key="yAxes1.ticks.max" .value=${this.yAxes1.ticks.max} />
178
+ `
179
+ : html``}
180
+
181
+ <label> <i18n-msg msgid="label.axis-step-size">StepSize</i18n-msg> </label>
182
+ <input type="number" value-key="yAxes1.ticks.stepSize" .value=${this.yAxes1.ticks.stepSize} />
183
+
184
+ <input
185
+ type="checkbox"
186
+ value-key="value.options.y2ndGridLine"
187
+ .checked=${props.value.options.y2ndGridLine}
188
+ />
189
+ <label> <i18n-msg msgid="label.grid-line">Grid Line</i18n-msg> </label>
190
+
191
+ <input type="checkbox" value-key="yAxes1.ticks.display" .checked=${this.yAxes1.ticks.display} />
192
+ <label> <i18n-msg msgid="label.display-tick">Display Tick</i18n-msg> </label>
193
+ `
194
+ : html``}
195
+ `
196
+ }
197
+
198
+ _hasBarSeries(chart: any) {
199
+ var hasBarSeries = false
200
+ hasBarSeries = chart.data.datasets.some((s: any) => s.type == 'bar')
201
+
202
+ return hasBarSeries
203
+ }
204
+ }