-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acea8ee
commit f734ecb
Showing
17 changed files
with
522 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { AxisDefaultized } from '../models/axis'; | ||
import { DefaultizedBarSeriesType } from '../models/seriesType/bar'; | ||
|
||
export default function getColor( | ||
series: DefaultizedBarSeriesType, | ||
xAxis: AxisDefaultized, | ||
yAxis: AxisDefaultized, | ||
) { | ||
const verticalLayout = series.layout === 'vertical'; | ||
|
||
const bandColorScale = verticalLayout ? xAxis.colorScale : yAxis.colorScale; | ||
const valueColorScale = verticalLayout ? yAxis.colorScale : xAxis.colorScale; | ||
const bandValues = verticalLayout ? xAxis.data! : yAxis.data!; | ||
|
||
if (valueColorScale) { | ||
return (dataIndex: number) => { | ||
const value = series.data[dataIndex]; | ||
const color = value === null ? series.color : valueColorScale(value); | ||
if (color === null) { | ||
return series.color; | ||
} | ||
return color; | ||
}; | ||
} | ||
if (bandColorScale) { | ||
return (dataIndex: number) => { | ||
const value = bandValues[dataIndex]; | ||
const color = value === null ? series.color : bandColorScale(value); | ||
if (color === null) { | ||
return series.color; | ||
} | ||
return color; | ||
}; | ||
} | ||
return () => series.color; | ||
} |
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
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,34 @@ | ||
import { AxisDefaultized } from '../models/axis'; | ||
import { DefaultizedLineSeriesType } from '../models/seriesType/line'; | ||
|
||
export default function getColor( | ||
series: DefaultizedLineSeriesType, | ||
xAxis: AxisDefaultized, | ||
yAxis: AxisDefaultized, | ||
) { | ||
const yColorScale = yAxis.colorScale; | ||
const xColorScale = xAxis.colorScale; | ||
|
||
if (yColorScale) { | ||
return (dataIndex: number) => { | ||
const value = series.data[dataIndex]; | ||
const color = value === null ? series.color : yColorScale(value); | ||
if (color === null) { | ||
return series.color; | ||
} | ||
return color; | ||
}; | ||
} | ||
if (xColorScale) { | ||
return (dataIndex: number) => { | ||
const value = xAxis.data?.[dataIndex]; | ||
const color = value === null ? series.color : xColorScale(value); | ||
if (color === null) { | ||
return series.color; | ||
} | ||
return color; | ||
}; | ||
} | ||
|
||
return () => series.color; | ||
} |
Oops, something went wrong.