# Use gridPos for scripted dashboard

**URL:** <https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692>\
**Category:** Grafana\
**Created:** [April 9, 2018, 10:55am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692 "2018-04-09T10:55:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![viapass](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/viapass/32/1000_2.png) [@viapass](https://community.grafana.com/u/viapass)\
**Post date:** [April 9, 2018, 10:55am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/1 "2018-04-09T10:55:09Z")

</div>

Hi all,

I made a dashboard that looks like this :

 ![test](https://us1.discourse-cdn.com/grafana/original/2X/1/19724d8c9048bb73bb72c71256b4d0e2e86aee80.PNG)

And I want to make a script that makes the same dashboard, but on an older version of Grafana I used “dashboard.rows.push” to make dashboard looks the way I wanted but with the actual Grafana’s version my script makes dashboards looking like this :

 ![test2](https://us1.discourse-cdn.com/grafana/original/2X/6/63db1645eb6c2b5128eccdcf7b684ecd91d657b9.PNG)

As you can see on the first screenshot my panel is on two rows, is there an equivalent of “dashboard.rows.push” working with gridPos ? Or any other way that could help me ?

Thanks.

---

<div class="post-metadata">

**Author:** ![daniellee](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/daniellee/32/41_2.png) [@daniellee](https://community.grafana.com/u/daniellee)\
**Post date:** [April 10, 2018, 4:08pm UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/2 "2018-04-10T16:08:40Z")

</div>

A row is now a sort of panel but in your case I don’t think you need rows at all. There is a panels array now instead of a rows array.

The way to handle the x,y coordinates and the height and width is the [gridPos object](http://docs.grafana.org/reference/dashboard/#panel-size-position). The grid is 24 slots wide so setting `w` to 24 is full width, 12 would be half and for the height each point is 30 pixels (so 10 would be 300 pixels).

See below for an example:

```auto
dashboard.panels.push({
    title: 'Events',
    type: 'graph',
    linewidth: 2,
    gridPos: {
      h: 10,
      w: 24,
      x: 0,
      y: 10,
    },
....

```

I noticed that the scripted dashboard examples with Grafana are out of date so I’ll update those and the docs.

---

<div class="post-metadata">

**Author:** ![viapass](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/viapass/32/1000_2.png) [@viapass](https://community.grafana.com/u/viapass)\
**Post date:** [April 11, 2018, 10:35am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/3 "2018-04-11T10:35:40Z")

</div>

Thanks for your help, I’m gonna try what you said. And thank you for updating the docs 🙂

---

<div class="post-metadata">

**Author:** ![mahadev](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/mahadev/32/4173_2.png) [@mahadev](https://community.grafana.com/u/mahadev)\
**Post date:** [June 7, 2018, 6:17am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/4 "2018-06-07T06:17:58Z")

</div>

Hi,

Is there any way to create Grafana dashboard as code with Python using Influxdb as datasource. Already I tried with Grafana lib but it doesn’t support influx.

Thanks

---

<div class="post-metadata">

**Author:** ![yajana](https://avatars.discourse-cdn.com/v4/letter/y/ba8739/32.png) [@yajana](https://community.grafana.com/u/yajana)\
**Post date:** [October 1, 2018, 11:58am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/5 "2018-10-01T11:58:00Z")

</div>

I am adding the grid position as

> {  
> title: ‘CPU Usage’,  
> type: ‘graph’,  
> linewidth: 2,  
> gridPos: {  
> x: 0,  
> y: 4,  
> w: 12,  
> h: 10  
> },  
> fill: 1,  
> datasource: ‘telegraf’,  
> targets: [ …  
> },

But when I open the file in grafana am getting json as

> “gridPos”: {  
> “x”: 0,  
> “y”: 4,  
> “w”: 8,  
> “h”: 7  
> },

Did I miss anything?

---

<div class="post-metadata">

**Author:** ![xim](https://avatars.discourse-cdn.com/v4/letter/x/c89c15/32.png) [@xim](https://community.grafana.com/u/xim)\
**Post date:** [March 1, 2019, 9:29am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/6 "2019-03-01T09:29:24Z")

</div>

I’m getting the same result as you. Did you fix it?  
Thank you

---

<div class="post-metadata">

**Author:** ![nereu](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@nereu](https://community.grafana.com/u/nereu)\
**Post date:** [August 7, 2019, 5:08pm UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/7 "2019-08-07T17:08:56Z")

</div>

I have the same issue with gridpos, in the same row we can use the span, ie:  
panels: [{  
title: ‘panel text 1’,  
type: ‘text’,  
height: ‘400px’,  
span: 4,  
fill: 1,  
content: ‘# 1’  
},{  
title: ‘panel text 2’,  
type: ‘text’,  
height: ‘400px’,  
span: 8,  
fill: 1,  
content: ‘# 2’  
} …

---

<div class="post-metadata">

**Author:** ![brunofl](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@brunofl](https://community.grafana.com/u/brunofl)\
**Post date:** [March 10, 2020, 1:31am UTC](https://community.grafana.com/t/use-gridpos-for-scripted-dashboard/6692/8 "2020-03-10T01:31:10Z")

</div>

I generated the json for a dashboard with 120 panels, each line should present a {Text panel}, a {singlestat panel} and {2 gauge panels}.  
Text panel has width 6, height 3.  
All other panels has has height 3 and width 2.  
When I paste the json with the arrays generated it seems to crash, as a lot of panels get overlaid.  
if I input each panel json individually they work, from the second line on it starts get messing.  
But when I past all its like chaos, several panels overlayd and singlestat and gauge panels assuming position and size of the Text panels.  
What should be a good practice to follow in order to prevent this from happening.  
the grid position and sizes of the panels looks mathematically correct.

Is there something I can do to prevent this issue from happening?
