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

MMM-GrafanaChart panels side by side #15

Open
codac opened this issue Nov 24, 2022 · 5 comments
Open

MMM-GrafanaChart panels side by side #15

codac opened this issue Nov 24, 2022 · 5 comments

Comments

@codac
Copy link

codac commented Nov 24, 2022

Hi Guys, I have a dashboard in Grafana which I would like to display on the MagicMirror with MMM-GrafanaChart.
As MMM-GrafanaChart works with PanelIDs with each module array I can only display one panel instead of the whole Dashboard.
So what I would like to achieve with CSS is to have one panel on top-right in the first row and in the second row I would like to have 3 different panels right next side-by-side.
How would the solution look like?

@iskrenpp
Copy link
Contributor

iskrenpp commented Mar 31, 2023

I was able to do that the following way.
I have added 2 rows of equal size panels - 3 panels on each row and they look the same size.
Now the current master branch of this module still has a bug where the percentage height does not work. Reading some other issues here it looks like height in pixels works in the config.js.
But in my case I kept all panels in config.js same 100% for width and height.
Then in css/custom.css I added same section with matching module name from the HTML elements as this

#module_11_MMM-GrafanaChart iframe {
  width: 650px;
  height: 500px;
}

This effectively resizes the iframe container that holds the chart. Since this is in px and is strictly dependent on the display resolution there will be some finetunning with the correct / best pixel values depending on it.
Also in config.js for each chart I use in sequence positions: top_left, top center, top_right, bottom_left, bottom_center, bottom_right
TIP: once you add modules in config.js DO NOT switch their order in the array. Always add new modules at the end of the array. Otherwise the html element module index will change e.g. module_X
and this will break your custom css
@codac I hope this ^^ helps

@klaernie
Copy link
Member

@iskrenpp : You found the best solution - setting it in stone using CSS. However we should maybe think about adding a config option to set the id attribute of the iframe directly in the config, so writing CSS for it becomes better maintainable.

@Rene1695
Copy link

Rene1695 commented May 1, 2023

Hey,

can i get more details on how to realize this? Could you provide an example config.js and css file?

@klaernie
Copy link
Member

klaernie commented May 4, 2023

It's this simple:

modules: [
	{
		module: 'MMM-GrafanaChart',
		position: 'top_right',
		config: {
				url: "https://localhost:5000/....",
				width: "100%",
				height: "69px", // Optional. Default: 100%
				scrolling: "no",
				refreshInterval: 900
		}
	},
]

We actually have a config option for this, so resorting to CSS is not even needed.

@Rene1695
Copy link

Rene1695 commented May 5, 2023

Hey,

thanks for the reply. Sorry for the misunderstanding, what i meant was to get multiple charts side-by-side. If, for example, two charts were added and position of both is set to "top_left", both charts will be put underneath. Is it possible to put them in the same row?

I also have other stuff in my mirror and would like to keep their positions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants