Console Reference: c3Matrix
c3Matrix generates a 2-D representation of data with rows and columns using DataGrid. The function returns this representation in the form of a JavaScript array.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
data | ✓ | Type | The C3 Type (or Type Collection) to be represented |
options | object | A key-value object with options for rendering the DataGrid |
Returns
An object with the following properties:
- index: A zero-indexed number related to the input object's position.
- values: A list of column values from each object. If no options are provided, this will be values from the supplied object or objects.
Example
Use c3Matrix on a single Type instance:
JavaScript
const mfc = Manufacturer.make({ fullName: "Honda", id: "honda-1234" });
c3Matrix(mfc);
// returns [{ index: 0, values: ['honda-1234', 'Honda'] }]Use c3Matrix on a Type collection:
JavaScript
const mfcs = [
Manufacturer.make({ fullName: "Honda", id: "honda-1234" }),
Manufacturer.make({ fullName: "Ford", id: "ford-1234" }),
Manufacturer.make({ fullName: "Nissan", id: "nissan-1234" }),
];
c3Matrix(mfcs);
/*
returns [
{ index: 0, values: ['honda-1234', 'Honda'] },
{ index: 1, values: ['ford-1234', 'Ford'] },
{ index: 2, values: ['nissan-1234', 'Nissan'] },
]
*/