]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
[types][beta-5] fixed stacked scale, changed default type for data.labels (#8001)
authorxr0master <xr0master@gmail.com>
Thu, 5 Nov 2020 14:12:25 +0000 (16:12 +0200)
committerGitHub <noreply@github.com>
Thu, 5 Nov 2020 14:12:25 +0000 (09:12 -0500)
* Scale: added the stacked property for all scales
* interfaces: generic type LABEL can be string, Date, etc.
* controllers: stack can be used for all types of dataset
* docs/data-structures: added general dataset properties

Co-authored-by: Sergey Khomushin <sergey@placer.io>
docs/docs/general/data-structures.md
types/controllers/index.d.ts
types/interfaces.d.ts
types/scales/index.d.ts

index 1d53bbe7e9b38e4dbfe0933e087df8066cf3d0a3..9820fd3ff7f734b9e47adec607e56a51f49b0887 100644 (file)
@@ -46,7 +46,28 @@ options: {
 }
 ```
 
-### `parsing` can also be specified per dataset
+## Object
+
+```javascript
+data: {
+    January: 10,
+    February: 20
+}
+```
+
+In this mode, property name is used for `index` scale and value for `value` scale. For vertical charts, index scale is `x` and value scale is `y`.
+
+## Dataset Configuration
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `string` | The label for the dataset which appears in the legend and tooltips.
+| `clip` | <code>number&#124;object</code> | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. 0 = clip at chartArea. Clipping can also be configured per side: clip: {left: 5, top: false, right: -2, bottom: 0}
+| `order` | `number` | The drawing order of dataset. Also affects order for stacking, tooltip and legend.
+| `stack` | `string` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack).
+| `parsing` | <code>boolean&#124;object</code> | How to parse the dataset. The parsing can be disabled by specifying parsing: false at chart options or dataset. If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
+
+### parsing
 
 ```javascript
 const data = [{x: 'Jan', net: 100, cogs: 50, gm: 50}, {x: 'Feb', net: 120, cogs: 55, gm: 75}];
@@ -76,14 +97,3 @@ const cfg = {
     },
 };
 ```
-
-## Object
-
-```javascript
-data: {
-    January: 10,
-    February: 20
-}
-```
-
-In this mode, property name is used for `index` scale and value for `value` scale. For vertical charts, index scale is `x` and value scale is `y`.
index f7fce5e26a173f6de810565dd1ecc80df4ea7ca2..16d696a6b5bf07bb3fe2a84c24ca72d874e6cf78 100644 (file)
@@ -26,6 +26,11 @@ export interface IControllerDatasetOptions {
    * The drawing order of dataset. Also affects order for stacking, tooltip and legend.
    */
   order: number;
+
+  /**
+   * The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack).
+   */
+  stack: string;
 }
 
 export interface IBarControllerDatasetOptions
@@ -71,11 +76,6 @@ export interface IBarControllerDatasetOptions
    * Set this to ensure that bars have a minimum length in pixels.
    */
   minBarLength: number;
-
-  /**
-   * The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack).
-   */
-  stack: string;
 }
 
 export interface IBarControllerChartOptions {
index dff4691e77a8d2dc995907832b197e478bf6a4c4..90199c0bc4dbbcd45594d63488b557614a0d6981 100644 (file)
@@ -176,7 +176,7 @@ export type IChartDataset<
 export interface IChartData<
   TYPE extends IChartType = IChartType,
   DATA extends unknown[] = DefaultDataPoint<TYPE>,
-  LABEL = string
+  LABEL = unknown
 > {
   labels: LABEL[];
   datasets: IChartDataset<TYPE, DATA>[];
index 857be7f64e5f8c802cfa5ff8d33fa54571cd9673..e31e478e7dbfe837b89ea72da462c34c8e40d383 100644 (file)
@@ -122,6 +122,12 @@ export interface ICartesianScaleOptions extends ICoreScaleOptions {
     };
   };
 
+       /**
+        *      If true, data will be comprised between datasets of data
+        * @default false
+        */
+  stacked?: boolean;
+
   ticks: ITickOptions & {
     /**
      * The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
@@ -193,7 +199,6 @@ export const CategoryScale: IChartComponent & {
 };
 
 export type ILinearScaleOptions = ICartesianScaleOptions & {
-  stacked?: boolean;
 
   /**
    *   if true, scale will include 0 if it is not already included.
@@ -243,7 +248,6 @@ export const LinearScale: IChartComponent & {
 };
 
 export type ILogarithmicScaleOptions = ICartesianScaleOptions & {
-  stacked?: boolean;
 
   /**
    * Adjustment used when calculating the maximum data value.