-
Notifications
You must be signed in to change notification settings - Fork 2
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
353e3ad
commit 2f0a0c4
Showing
8 changed files
with
225 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
import { Component, createRef } from "react"; | ||
|
||
import Chartjs from "chart.js/auto"; | ||
|
||
export default class Chart extends Component { | ||
chartRef = createRef(); | ||
|
||
componentDidMount() { | ||
const myChartRef = this.chartRef.current.getContext("2d"); | ||
new Chartjs(myChartRef, { | ||
type: this.props.type, | ||
data: this.props.data, | ||
options: this.props.options, | ||
}); | ||
} | ||
|
||
render() { | ||
return <canvas style={{ height: "auto" }} ref={this.chartRef}></canvas>; | ||
} | ||
} |
Binary file not shown.
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,52 @@ | ||
const color = { | ||
firstTemColors(i) { | ||
const colors = [ | ||
"#084887", | ||
"#dc3912", | ||
"#3366cc", | ||
"#7F2CCB", | ||
"#5D2E46", | ||
"#A62639", | ||
"#F58A07", | ||
"#3454D1", | ||
"#34D1BF", | ||
]; | ||
return colors[i]; | ||
}, | ||
colorContrast(bgColor, lightColor, darkColor) { | ||
var color = bgColor.charAt(0) === "#" ? bgColor.substring(1, 7) : bgColor; | ||
var r = parseInt(color.substring(0, 2), 16); // hexToR | ||
var g = parseInt(color.substring(2, 4), 16); // hexToG | ||
var b = parseInt(color.substring(4, 6), 16); // hexToB | ||
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? darkColor : lightColor; | ||
}, | ||
string2Hex(str) { | ||
switch (str.toLowerCase()) { | ||
case "positive": | ||
return "#66c333"; | ||
case "negative": | ||
return "#ca3030"; | ||
case "neutral": | ||
return "#285488"; | ||
case "unclassified": | ||
return "#e3e3e4"; | ||
} | ||
|
||
return `#${this.intToRGB(this.hashCode(str))}`; | ||
}, | ||
hashCode(str) { | ||
str = str || ""; | ||
let hash = 0; | ||
for (let i = 0; i < str.length; i++) { | ||
hash = str.charCodeAt(i) + ((hash << 5) - hash); | ||
} | ||
return hash; | ||
}, | ||
intToRGB(i) { | ||
let c = (i & 0x00ffffff).toString(16).toUpperCase(); | ||
|
||
return "00000".substring(0, 6 - c.length) + c; | ||
}, | ||
}; | ||
|
||
export default 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