-
Notifications
You must be signed in to change notification settings - Fork 0
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
d85fb11
commit e3b0b09
Showing
4 changed files
with
178 additions
and
3 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,42 @@ | ||
import { useEffect } from 'react'; | ||
|
||
const IslandBarChart = () => { | ||
useEffect(() => { | ||
import('plotly.js-dist').then((Plotly) => { | ||
const xValues = ['Big Island', 'Kauai', 'Lanai', 'Maui', 'Molokai', 'Oahu']; | ||
const yTrace1 = [20, 14, 23, 34, 5, 20]; | ||
const yTrace2 = [2, 4, 7, 6, 2, 10]; | ||
|
||
const trace1Color = 'rgb(50, 130, 180)'; | ||
const trace2Color = 'rgb(200, 100, 0)'; | ||
|
||
const trace1 = { | ||
x: xValues, | ||
y: yTrace1, | ||
name: 'Removed', | ||
type: 'bar', | ||
marker: { color: trace1Color }, | ||
}; | ||
|
||
const trace2 = { | ||
x: xValues, | ||
y: yTrace2, | ||
name: 'Not Removed', | ||
type: 'bar', | ||
marker: { color: trace2Color }, | ||
}; | ||
|
||
const data = [trace1, trace2]; | ||
|
||
const layout = { | ||
barmode: 'group', | ||
}; | ||
|
||
Plotly.newPlot('islandBarChart', data, layout, {displayModeBar: false}); | ||
}); | ||
}, []); | ||
|
||
return <div id="islandBarChart" />; | ||
}; | ||
|
||
export default IslandBarChart; |
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,97 @@ | ||
import { useEffect } from "react"; | ||
|
||
const ReporTimesSeries = () => { | ||
useEffect(() => { | ||
import("plotly.js-dist").then((Plotly) => { | ||
const data = [ | ||
{ | ||
Month: "2015-02", | ||
"Organization1": 130.0, | ||
"Organization2": 120.0, | ||
}, | ||
{ | ||
Month: "2015-03", | ||
"Organization1": 135.0, | ||
"Organization2": 125.0, | ||
}, | ||
{ | ||
Month: "2015-04", | ||
"Organization1": 140.0, | ||
"Organization2": 130.0, | ||
}, | ||
// Continue with the next months | ||
{ | ||
Month: "2017-01", | ||
"Organization1": 150.0, | ||
"Organization2": 140.0, | ||
}, | ||
{ | ||
Month: "2017-02", | ||
"Organization1": 160.0, | ||
"Organization2": 150.0, | ||
}, | ||
]; | ||
|
||
function unpack(rows, key) { | ||
return rows.map((row) => row[key]); | ||
} | ||
|
||
const trace1 = { | ||
type: "scatter", | ||
mode: "lines", | ||
name: "Organization 2", | ||
x: unpack(data, "Month"), | ||
y: unpack(data, "Organization1"), | ||
line: { color: "#17BECF" }, | ||
}; | ||
|
||
const trace2 = { | ||
type: "scatter", | ||
mode: "lines", | ||
name: "Organization 1", | ||
x: unpack(data, "Month"), | ||
y: unpack(data, "Organization2"), | ||
line: { color: "#7F7F7F" }, | ||
}; | ||
|
||
const chartData = [trace1, trace2]; | ||
|
||
const layout = { | ||
xaxis: { | ||
autorange: true, | ||
range: ["2015-02-17", "2017-02-16"], | ||
rangeselector: { | ||
buttons: [ | ||
{ | ||
count: 6, | ||
label: "6m", | ||
step: "month", | ||
stepmode: "backward", | ||
}, | ||
{ | ||
count: 12, | ||
label: "1y", | ||
step: "month", | ||
stepmode: "backward", | ||
}, | ||
{ step: "all" }, | ||
], | ||
}, | ||
rangeslider: { range: ["2015-02", "2017-02"] }, | ||
type: "date", | ||
tickformat: "%Y-%m", | ||
}, | ||
yaxis: { | ||
autorange: true, | ||
type: "linear", | ||
}, | ||
}; | ||
|
||
Plotly.newPlot("reportTimeSeries", chartData, layout); | ||
}); | ||
}, []); | ||
|
||
return <div id="reportTimeSeries"></div>; | ||
}; | ||
|
||
export default ReporTimesSeries; |
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