Working JavaScript charts
[gpl/argeo-suite.git] / js / src / chart / ChartPart.js
diff --git a/js/src/chart/ChartPart.js b/js/src/chart/ChartPart.js
new file mode 100644 (file)
index 0000000..1fe9221
--- /dev/null
@@ -0,0 +1,34 @@
+/** API to be used by Java.
+ *  @module MapPart
+ */
+
+/** Abstract base class for displaying a map. */
+export default class ChartPart {
+
+       /** The name of the chart, will also be the name of the variable */
+       #chartName;
+
+       constructor(chartName) {
+               this.#chartName = chartName;
+               this.createChartCanvas(this.#chartName);
+       }
+
+
+       //
+       // HTML
+       //
+       /** Create the div element where the chart will be displayed. */
+       createChartCanvas(id) {
+               const chartDiv = document.createElement('canvas');
+               chartDiv.id = id;
+               //chartDiv.style.cssText = 'width: 100%;';
+               chartDiv.style.cssText = 'width: 100%; height: 100vh;';
+               document.body.appendChild(chartDiv);
+       }
+
+       /** Get the div element where the chart is displayed. */
+       getChartCanvas() {
+               return document.getElementById(this.#chartName);
+       }
+
+}
\ No newline at end of file