Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for each dataset to be individually typed without a main type (#…
…10387) * allow for each dataset to be individually typed without a main type * fix lint issues * add extra test cases
- Loading branch information
1 parent
1a1151b
commit 2486fe2
Showing
2 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Chart } from '../index.esm'; | ||
|
||
const chart = new Chart('chart', { | ||
type: 'bar', | ||
data: { | ||
labels: ['1', '2', '3'], | ||
datasets: [{ | ||
data: [1, 2, 3] | ||
}, | ||
{ | ||
data: [1, 2, 3], | ||
categoryPercentage: 10 | ||
}], | ||
} | ||
}); | ||
|
||
const chart2 = new Chart('chart', { | ||
type: 'bar', | ||
data: { | ||
labels: ['1', '2', '3'], | ||
datasets: [{ | ||
type: 'line', | ||
data: [1, 2, 3], | ||
// @ts-expect-error should not allow bar properties to be defined in a line dataset | ||
categoryPercentage: 10 | ||
}, | ||
{ | ||
type: 'line', | ||
pointBackgroundColor: 'red', | ||
data: [1, 2, 3] | ||
}, | ||
{ | ||
data: [1, 2, 3], | ||
categoryPercentage: 10 | ||
}], | ||
} | ||
}); | ||
|
||
const chart3 = new Chart('chart', { | ||
data: { | ||
labels: ['1', '2', '3'], | ||
datasets: [{ | ||
type: 'bar', | ||
data: [1, 2, 3], | ||
categoryPercentage: 10 | ||
}, | ||
{ | ||
type: 'bar', | ||
data: [1, 2, 3], | ||
// @ts-expect-error should not allow line properties to be defined in a bar dataset | ||
pointBackgroundColor: 'red', | ||
}], | ||
} | ||
}); | ||
|
||
// @ts-expect-error all datasets should have a type property or a default fallback type should be set | ||
const chart4 = new Chart('chart', { | ||
data: { | ||
labels: ['1', '2', '3'], | ||
datasets: [{ | ||
type: 'bar', | ||
data: [1, 2, 3], | ||
categoryPercentage: 10 | ||
}, | ||
{ | ||
data: [1, 2, 3] | ||
}], | ||
} | ||
}); |