Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17 add logos to the plot uob metoffice national centre for atmospheric science #20

14 changes: 12 additions & 2 deletions src/components/DensityMap/DensityMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import React from "react";
import Plot from "react-plotly.js";
import { extend } from "lodash";

import styles from "./DensityMap.module.css";

import ch4MobileGlasgow from "../../data/ch4_mobile_glasgow.json";
import { createImage } from "../../util/helpers"
import openghg from "../../images/OpenGHG_Logo_Landscape.png"

class DensityMap extends React.Component {
render() {
Expand All @@ -26,6 +26,10 @@ class DensityMap extends React.Component {
const height = 400;
const width = this.props.width;

const uniOfBristol = require(`../../images/UniOfBristolLogo.png`);
const metOffice = require(`../../images/Metoffice.png`);
const ncas = require(`../../images/ncas.png`);

const layout = {
mapbox: { center: { lon: -4.212836, lat: 55.843658 }, style: "open-street-map", zoom: 10 },
coloraxis: {
Expand All @@ -35,6 +39,12 @@ class DensityMap extends React.Component {
margin: { t: 30, b: 30, l: 30, r: 30 },
width: width,
height: height,
images: [
createImage(openghg, 0.1),
createImage(uniOfBristol, 0.22),
createImage(metOffice, 0.31),
createImage(ncas, 0.41),
],
};

return (
Expand Down
14 changes: 13 additions & 1 deletion src/components/LineChart/LineChart.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import PropTypes from "prop-types";
import React from "react";
import Plot from "react-plotly.js";

import styles from "./LineChart.module.css";
import { createImage } from "../../util/helpers"


class LineChart extends React.Component {
render() {
Expand Down Expand Up @@ -70,6 +71,11 @@ class LineChart extends React.Component {

const widthScaleFactor = 0.925;

const uniOfBristol = require(`../../images/UniOfBristolLogo.png`);
const metOffice = require(`../../images/Metoffice.png`);
const ncas = require(`../../images/ncas.png`);
const openghg = require(`../../images/OpenGHG_Logo_Landscape.png`);

const layout = {
title: {
text: this.props.title ? this.props.title : null,
Expand Down Expand Up @@ -110,6 +116,12 @@ class LineChart extends React.Component {
pad: 5,
},
shapes: [dateMarkObject],
images: [
createImage(openghg, 0.1),
createImage(uniOfBristol, 0.22),
createImage(metOffice, 0.31),
createImage(ncas, 0.41),
],
};

return (
Expand Down
13 changes: 13 additions & 0 deletions src/components/MultiSiteLineChart/MultiSiteLineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React from "react";
import Plot from "react-plotly.js";
import { toTitleCase } from "../../util/helpers";
import styles from "./MultiSiteLineChart.module.css";
import { createImage } from "../../util/helpers"

import colours from "../../data/colours.json";

class MultiSiteLineChart extends React.Component {
Expand Down Expand Up @@ -81,6 +83,10 @@ class MultiSiteLineChart extends React.Component {
}

const widthScaleFactor = 0.925;
const uniOfBristol = require(`../../images/UniOfBristolLogo.png`);
const metOffice = require(`../../images/Metoffice.png`);
const ncas = require(`../../images/ncas.png`);
const openghg = require(`../../images/OpenGHG_Logo_Landscape.png`);

const layout = {
title: {
Expand All @@ -92,6 +98,12 @@ class MultiSiteLineChart extends React.Component {
y: 0.97,
yanchor: "top",
},
images: [
createImage(openghg, 0.1),
createImage(uniOfBristol, 0.22),
createImage(metOffice, 0.31),
createImage(ncas, 0.41),
],
xaxis: {
range: this.props.xRange ? this.props.xRange : null,
showgrid: false,
Expand Down Expand Up @@ -134,6 +146,7 @@ class MultiSiteLineChart extends React.Component {
<div data-testid={"linePlot"} className={styles.container}>
<Plot data={plotData} layout={layout} />
</div>

);
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/components/ScatterMap/ScatterMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import Plot from "react-plotly.js";
import styles from "./ScatterMap.module.css";

import ch4MobileGlasgow from "../../data/ch4_mobile_glasgow.json";
import { createImage } from "../../util/helpers"
import openghg from "../../images/OpenGHG_Logo_Landscape.png"


class ScatterMap extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -63,12 +66,22 @@ class ScatterMap extends React.Component {
const width = this.props.width;
const plotData = this.state.plotData;

const uniOfBristol = require(`../../images/UniOfBristolLogo.png`);
const metOffice = require(`../../images/Metoffice.png`);
const ncas = require(`../../images/ncas.png`);

const layout = {
mapbox: { center: { lon: -4.212836, lat: 55.843658 }, style: "open-street-map", zoom: 10 },
coloraxis: {
colorscale: "Viridis",
colorbar: { title: { side: "right", text: "Methane (ppb)", font: { size: 16 } } },
},
images: [
createImage(openghg, 0.1),
createImage(uniOfBristol, 0.22),
createImage(metOffice, 0.31),
createImage(ncas, 0.41),
],
margin: { t: 30, b: 30, l: 30, r: 30 },
width: width,
height: height,
Expand Down
Binary file added src/images/Metoffice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/OpenGHG_Logo_Landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/UniOfBristolLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/ncas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/util/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ export function getVisID() {
export function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
/**
* Creates an image object for the layout.
*
* @param {string} source - The image source URL.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I like the docstring.

* @param {number} x - The horizontal position of the image.
* @param {number} [opacity=0.6] - The opacity of the image.
* @returns {Object} The image object for the layout.
*/
export function createImage(source, x, opacity = 0.6) {
return {
source: source,
xref: 'paper',
yref: 'paper',
x: x,
y: 0.89,
sizex: 0.12,
sizey: 0.12,
opacity: opacity,
xanchor: 'center',
yanchor: 'middle',
}};

// export function importSVGs() {
// let footprints = {};
Expand Down
Loading