This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
BarChart
; fix: typo; fix: color alpha (#23)
* fix(widgets): fix color alpha not applied * fix(docs): fix typo * feat: `BarChart`
- Loading branch information
1 parent
01936ab
commit 809e645
Showing
19 changed files
with
217 additions
and
87 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './widgets' | ||
export * from './utils' |
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import type { Color } from '@newcar/utils' | ||
import type { ChartDataUnit } from '../widgets' | ||
|
||
export interface ChartData { | ||
export interface ChartData<ChartStyle> { | ||
labels: string[] | ||
datasets: { | ||
label: string | ||
data: number[] | ||
backgroundColor?: Color[] | ||
borderColor?: Color[] | ||
borderWidth?: number | ||
borderRadius?: number | ||
data: ChartDataUnit<ChartStyle>[] | ||
style?: ChartStyle | ||
}[] | ||
} |
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,9 @@ | ||
import type { Color } from '@newcar/utils' | ||
import type { WidgetStyle } from '@newcar/core' | ||
|
||
export interface ChartStyle extends WidgetStyle { | ||
backgroundColor?: Color | ||
borderColor?: Color | ||
borderWidth?: number | ||
border?: boolean | ||
} |
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,8 @@ | ||
import type { ChartDataOptions } from '../widgets' | ||
import { ChartDataUnit } from '../widgets' | ||
|
||
export class ChartUtil { | ||
static dataUnits<ChartStyle>(data: number[], options?: ChartDataOptions<ChartStyle>): ChartDataUnit<ChartStyle>[] { | ||
return data.map(value => new ChartDataUnit(value, options)) | ||
} | ||
} |
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,4 @@ | ||
export * from './chartData' | ||
export * from './chartStyle' | ||
export * from './chartOption' | ||
export * from './chartUtil' |
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,15 @@ | ||
import { Widget, type WidgetOptions } from '@newcar/core' | ||
|
||
export interface ChartDataOptions<ChartStyle> extends WidgetOptions { | ||
style?: ChartStyle | ||
} | ||
|
||
export class ChartDataUnit<ChartStyle> extends Widget { | ||
declare style: ChartStyle | ||
|
||
constructor(public value: number, options?: ChartDataOptions<ChartStyle>) { | ||
options ??= {} | ||
super(options) | ||
this.style = options.style ?? {} as ChartStyle | ||
} | ||
} |
Oops, something went wrong.