]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Scriptable title plugin options (#8764)
authorEvert Timberg <evert.timberg+github@gmail.com>
Thu, 1 Apr 2021 07:16:03 +0000 (03:16 -0400)
committerGitHub <noreply@github.com>
Thu, 1 Apr 2021 07:16:03 +0000 (10:16 +0300)
src/plugins/plugin.title.js
test/fixtures/plugin.title/scriptable-options.js [new file with mode: 0644]
test/fixtures/plugin.title/scriptable-options.png [new file with mode: 0644]
test/specs/plugin.title.tests.js

index 3872a12d736306ed4dc85297009424e19d8f02d9..ba1f4ff67cf5046c9242af5616bf90872e702782 100644 (file)
@@ -160,4 +160,9 @@ export default {
   defaultRoutes: {
     color: 'color'
   },
+
+  descriptors: {
+    _scriptable: true,
+    _indexable: false,
+  },
 };
diff --git a/test/fixtures/plugin.title/scriptable-options.js b/test/fixtures/plugin.title/scriptable-options.js
new file mode 100644 (file)
index 0000000..f961fe2
--- /dev/null
@@ -0,0 +1,43 @@
+const data = [];
+for (let x = 0; x < 3; x++) {
+  for (let y = 0; y < 3; y++) {
+    data.push({x, y});
+  }
+}
+
+module.exports = {
+  config: {
+    type: 'scatter',
+    data: {
+      datasets: [{
+        data,
+        backgroundColor: 'red',
+        radius: 1,
+        hoverRadius: 0
+      }],
+    },
+    options: {
+      scales: {
+        x: {display: false},
+        y: {display: false}
+      },
+      plugins: {
+        legend: false,
+        title: {
+          display: true,
+          text: () => 'Title Text',
+        },
+        filler: false,
+        tooltip: false
+      },
+    },
+
+  },
+  options: {
+    spriteText: true,
+    canvas: {
+      height: 400,
+      width: 400
+    }
+  }
+};
diff --git a/test/fixtures/plugin.title/scriptable-options.png b/test/fixtures/plugin.title/scriptable-options.png
new file mode 100644 (file)
index 0000000..cf3ec7c
Binary files /dev/null and b/test/fixtures/plugin.title/scriptable-options.png differ
index fb9572380de47d87759d869afe8b9c71e8dc0f07..7c1c25849cf33e0bfe654bf516a751722ed9f77f 100644 (file)
@@ -2,7 +2,9 @@
 
 var Title = Chart.registry.getPlugin('title')._element;
 
-describe('Title block tests', function() {
+describe('Plugin.title', function() {
+  describe('auto', jasmine.fixture.specs('plugin.title'));
+
   it('Should have the correct default config', function() {
     expect(Chart.defaults.plugins.title).toEqual({
       align: 'center',