Giter VIP home page Giter VIP logo

vue-responsive-dash's Introduction

vue-responsive-dash

A Responsive, Draggable & Resizable Dashboard (grid) made with vue and typescript. Inspired by React-Grid-Layout & Vue-Grid-Layout

netlify deps code-size repo-size open-issues pull-req lic npm

Example: Edit Vue Template

⚙️ Installation

$ npm install vue-responsive-dash

📄 Documents

Link

🚀 How to use in Vue

<template>
  <div id="app">
    <dashboard :id="'dashExample'">
      <dash-layout v-for="layout in dlayouts" v-bind="layout" :debug="true" :key="layout.breakpoint">
        <dash-item v-for="item in layout.items" v-bind.sync="item" :key="item.id">
          <div class="content"></div>
        </dash-item>
      </dash-layout>
    </dashboard>
  </div>
</template>

<script>
import { Dashboard, DashLayout, DashItem } from "vue-responsive-dash";

export default {
  name: "App",
  components: {
    Dashboard,
    DashLayout,
    DashItem
  },
  data() {
    return {
      dlayouts: [
        {
          breakpoint: "xl",
          numberOfCols: 12,
          items: [
            { id: "1", x: 0, y: 0, width: 1, height: 1 },
            { id: "2", x: 1, y: 0, width: 2, height: 1 },
          ]
        },
        {
          breakpoint: "lg",
          breakpointWidth: 1200,
          numberOfCols: 10,
          items: [
            { id: "1", x: 0, y: 0, width: 1, height: 1 },
            { id: "2", x: 1, y: 0, width: 2, height: 1 },
          ]
        },
        {
          breakpoint: "md",
          breakpointWidth: 996,
          numberOfCols: 8,
          items: [
            { id: "1", x: 0, y: 0, width: 1, height: 1 },
            { id: "2", x: 1, y: 0, width: 2, height: 1 },
          ]
        },
        {
          breakpoint: "sm",
          breakpointWidth: 768,
          numberOfCols: 4,
          items: [
            { id: "1", x: 0, y: 0, width: 1, height: 1 },
            { id: "2", x: 1, y: 0, width: 2, height: 1 },
          ]
        },
        {
          breakpoint: "xs",
          breakpointWidth: 480,
          numberOfCols: 2,
          items: [
            { id: "1", x: 0, y: 0, width: 1, height: 1 },
            { id: "2", x: 1, y: 0, width: 1, height: 1 },
          ]
        },
        {
          breakpoint: "xxs",
          breakpointWidth: 0,
          numberOfCols: 1,
          items: [
            {
              id: "1",
              x: 0,
              y: 0,
              width: 1,
              height: 1
            },
            { id: "2", x: 0, y: 1, width: 1, height: 1 }
          ]
        }
      ]
    };
  }
};
</script>

<style>
.content {
  height: 100%;
  width: 100%;
  border: 2px solid #42b983;
  border-radius: 5px;
}
</style>

Grid Item Child Component

Edit Vue Template

See example above. The Grid Item object can be passed to the child component via props or injection. Typically the child component will look at the grid Item ID (which is unique) and decide what to render via a data/computed variable/s or VUEX.

See Example/Docs Website for more information.

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

👏 Contributing

If you have any questions or requests or want to contribute to vue-responsive-dash or other packages, please write the issue or give me a Pull Request freely.

🐞 Bug Report

If you find a bug, please report to us opening a new Issue on GitHub.

⚙️ Development

npm run serve

Runs the app in the development mode.
Open http://localhost:8080 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

vue-responsive-dash's People

Contributors

bensladden avatar dependabot-preview[bot] avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vue-responsive-dash's Issues

Trying to stack two dashboards on top of each other causes each item to be drawn on top of each other

I want to allow users to create new items in the spaces that there is no item already. I want to fill the empty spaces with items that let you create a panel there, like so:

image

The green panels would be draggable and resizable, but the gray ones would not be. Since adding gray items to the item array causes the green items to go crazy when trying to move them, I think the best way of doing this would be to draw two dashboards, the green one on top and the gray one on bottom. However, using position: absolute and setting the z-index on the layouts cause each item to be drawn on top of each other and each item becomes huge.

position: relative
image

position: absolute
image

Is there anything going on in the code that would be messed up by using position: absolute? Is there any way you can see to accomplish what I'm trying to do?

How to make Dash Items overlap

Hi @bensladden,
for a specific application I would like to have the Dash Items overlappable.

User will be able to add new Items in the Layout and draw and resize them freely even if they are colliding with other Items.
Is there any way to disable the collision detection so that other Items are not moved around when the new Item is added/moved/resized?

Thank you

Components inside dash-item mounted for lowest and current breakpoint.

Thank you for the very useful library.

I am having an issue, however, where components inside dash-item are mounted twice. It seems they are mounted for the smallest breakpoint first, then destroyed, and then for the current breakpoint. You can see it in this codesandbox. I've not noticed any other reports of this, but it certainly caused some confusion in my team. Any help (or clarification) you can offer would be great.

Thanks again.

Swapping Layouts moving dash-item

Hi

I have a problem with dynamically swapping between layouts, and have recreated the issue here

https://codesandbox.io/s/vue-responsive-dash-bvrwi

When you click the swap button it just swaps between two predefined layouts, however after you click swap twice all the boxes are moved to the bottom of the page, but they should be at the top like when it was first loaded.

I have found that the y positions are getting changed from the v-bind.sync="item" - an update:y is getting emitted for some reason and changing the layout.

This is critical to my project, hope you can find the issue.

Thanks
Peter

Autosize item height to grid item content

I didnt see anything for this in the documentation, unless I missed it
Is there a way to have a grid item autosize itself to the content's height?
My use case is fetching data from my API and populating widgets with it, so they're bound to be different heights

Nuxt SSR Support

I am trying to use the library in a nuxt project with SSR, but when installing the library it generates an error.
To solve this issue, I have to force the application to work SPA mode (the entire application, not only the page with responsive-dash)
I really would like very much to be able to use the library and keep the SSR functionality in the rest of the application

@bensladden Thanks in advance
image
image

Programmatically adding a Dash Item at the bottom of layout

Hi @bensladden,
in my application user has a button to add a new Item to a Layout.
The Layout is configured with compact:false so that the Items can be moved in the desired position and they stay there.
At the moment when the user adds a new Item this is created with x:0 and y:0 and pushed into the items list.
This works well but all other Items get moved when user adds and moves the new Item around.

I am wondering what is the best way to calculate the new Item x,y properties so that the new Item is located at the bottom of the layout. Let's say at x:0 but with a y such that it appears just below the last Item already present.

Is there any Layout property that could be exported? Something like Layout.maxheight that could give the actual maximum used height?

Or the only way is to scan the items list and find out the maximum y+height among all Items?

Thank you for any insight.

Allow setting ignoreFrom on DashItem's interactiveInstance attribute

In the scenario of having an interactive item (a chart with drag to see more values, etc.) this package should have a way to disable those elements to trigger a drag on DragItem component.

The same you have for dragAllowFrom, you should have a dragIgnoreFrom prop that will set the ignoreFrom on the interactiveInstance initialization options.

Buggy when using quickly

When I try to drag and drop quickly, the layout can often get to where two items overlap or the red item shows when I am not clicking anymore.

Examples:
image
image

Scrollbars and selects does not work inside dash items

Hi! I'm trying to put responsive tables with scrollbars and selects to choose what columns to display inside dash items but the drag event in items overrides the normal function of scrollbars and select elements make them unusable.

Thanks for your code, looks great!

Not receiving moveEnd for not dragging item

Hi.

Your component works well. I have a specific need.

About the event moveEnd event, I received the event for dropped item. But when I dropped it, other items were moved too.

Is there a way to know when other items moved ?

Information on purpose & vision for vue-responsive-dash

Hi,

I am unsure this is the right way to ask.

I have been tasked with updating an app which relies on vue-grid-layout.

We are puzzled by the decrease in activity / support witnessed on vue-grid-layout, and wondering whether it would make sense to make the effort to move to vue-responsive-dash, which looks great.

Hence our question: is there a place where you wrote why you decided to start this repo, and how you think it will evolve. I haven't been able to find an answer on the doc.

Thanks a lot, great work, Thib

Lock Dash Item coordinates

Hey it is easy or possible to add a feature to avoid one DashItem from moving out of this position if the draggable, resizable is set to false?

For example I may have something like this:

<dash-item id=1 draggable=false resizable=false/>
<dash-item id=2 draggable=true resizable=true/>

When I drag the item 2 to the place of item 1, the item one shifts its position to the next available slot... Ideally, I would like the item 1 to always stay at the given coordinates 0,0 and not allow item 2 to ever be on its place.. does it make sense?

Cannot set property id of #<DashItem> which has only a getter

Hi
I have started getting the following error when changing layouts dynamically since updating to 0.3.26
Do you have any ideas ? If not, I'll try and replicate the issue in https://codesandbox.io/ so you can have a look, hopefully I will be able to replicate the issue in a simple case.

I get the error when changing from one set of layouts to a completly separate set of layouts at the same breakpoint (screen size). The id's are different so its not a duplicate id issue. The crash caues the debug view not to update, but the error still occurs with debug turned off.

TypeError: Cannot set property id of #<DashItem> which has only a getter at VueComponent.handler (vue-responsive-dash.common.js?e6d2:10032) at Watcher.run (vue.runtime.esm.js?2b0e:4568) at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310) at Array.eval (vue.runtime.esm.js?2b0e:1980) at flushCallbacks (vue.runtime.esm.js?2b0e:1906)

Locked DashItem prevents touch scrolling

Hi Ben, love your work.

I've had great success with a global lock/unlock button toggling the locked property of each DashItem.

However, on devices with touch screens, scrolling is prevented whilst attempting to start a page scroll from a locked DashItem.

I hope I've explained the issue clear enough.
Any help would be much appreciated.

How to include components in the DashItems

Hello bensladden,
I am very interested in this component. However I cannot find any example of how to render some simple user-defined components inside the dash-item component.
It is mentioned that this shall be done using scope but I think some examples with a one or two simple user-defined components like a static text or an SVG icon could be very helpfull.
I am interested in understanding how a user component can be istantiated multiple times in different dash-items, having different sets of props in each istance and having this stored in data.

Thank you

[Feature Request] min/max column and row height/width and min/max item height/width

So I just found this component today and I really love it. It is simple to use and works pretty well.
But I really miss the option to set a minimum width and height vor Grid fields and also for items.
I am creating a currently nesting grids so that within an Item, there is another grid with just one column but each of the nested items do have same height as width and this is a bit annoying :)

Is this already planned for future and can I look forward to see this feature soon?

Greetings
Jan :)

Grid not readjusting when changing items

When I remove items from the grid the layout seems to adjust it self, but when I put the item back it stays the same, but if I start dragging any item it just reajust it self and fits perfectly.

There is a way to force the grid to reajust it self?

Like a refresh, so I can trigger in my watch event?

Cheers, nice work on the lib.

Vue3 Support

Will this work in Vue3? I tried but am seeing: "TypeError: cb.bind is not a function" error in console.

Loading charts when data is ready

I made a nice dashboard based on vue-responsive-dash with use of the apex-charts. See my screenshot bellow. This is a start for a dynamic dashboard where user can define each dash-item with any chart they can make. It all works. Now I've a question about the loading.

Each dash-item has a 'loading' section. Code wise it looks like this.

<div` v-if="bIsLoadedChart && bHasData" class="full-height">
<apex-chart-dash-item  :width="'100%'"  :height="'100%'" :type="oChart.type" :chartOptions="oChart.options" :series="oChart.series">
</apex-chart-dash-item>
</div>
<div v-else-if="bIsLoadedChart && !bHasData">No data...</div>
<div v-else class="full-height full-width">
<q-spinner-hourglass color="primary" style="position:relative; top: calc(50% - 2em); left: calc(50% - 2em);" size="2em" />
</div>

In the created of the template data is collected, labels made etc etc. When done, bIsLoadedChart is set to true. However, it seems that the chart is not appearing untill all the charts are ready. I verified this for the middle one (with the person icon) and right column number 3 and 4 actually don't need datafetching so when the template is created it is ready to be shown.

Is there something I can do to influence this behaviour?

image

I found a typo.

Hi, Ben.

I found a typo.

this.$emit("hovenEnd", this.item); => this.$emit("hoverEnd", this.item);

Thank you.

resizable flag does not work

Hi @bensladden,
from the documentation Layout.resizable should make the item resizable while Layout.draggable should make the Item draggable.

At the moment it seems that both features are tied togheter on the Layout.draggable prop while Layout.resizable does nothing.

Drag Drop into move mode

Hi

I am trying to get dragging a item from a list into dashboard and have it automatically add the new item and also go into moving mode without having to let go of the mouse button. So i can drag into the postion i want.

I have got the dragging working and the auto creating the dash-item, but i am having trouble going directly into move mode.

Here is a sample of where i am up to, you can drag the item at the top into the dashboard and it creates the dash-item, but if you continue to move the mouse around without letting of the mouse button, it doesnt drag the new dash-item around. (Not at least unles you let go and click mouse down again - which i am trying to avoid)

https://codesandbox.io/s/vue-responsive-dash-wn52w

Note i am using a simulate mouse function to try and trigger the change to move mode, but the mouse event doesn't seem to do the trick.
Do you have any suggestions on how to go into move mode from javascript ?

Thanks
Peter

Request: Don't move items until after the dragged item is dropped

It seems that displaying the red placeholder panel permanently moves the other panels, even if the item doesn't get dropped there. With the new compact prop, it would be nice if the items array doesn't get permanently changed until the item drop.

Example:

  1. before move
    image

  2. moving rightmost top panel to leftmost top position
    image

I would want the general and description panels to move down, but I would want the background panel not to move.

Create a slot for a "drag handle"?

Hi, we're enjoying this library, thanks for creating it! We need to make only the top part of a dash item draggable because we have other UI going on inside the item. What I did as a hack was just to select the drag listener for each dash item in CSS and resize it like so:

.item > div:first-of-type {
    bottom: auto !important;
    height: 24px !important;
}

This works, but I would rather be able to define specific styles with a slot for the drag handle like we can currently do with the resize slots. Seem like a heavy lift?

Thanks again!

Request: Be able to move by grabbing any of the child elements

Currently, this library works when having empty panels that you are moving around. It seems that if you have content inside the panels, to move, you need to actually grab the panel background.

Example:
image

When I put an overlay over the panel, I have to grab the pixel of white border to be able to move the item. The button also doesn't let me move the panel either.

Dash Item position issue on adding new item

Hi, I found this a good library to display responsive tiles in a grid though I'm having an issue while adding a new item into dash layout. I want to add a new item by clicking a button, it works well until I don't resize the item. After spending a few hours I figured out the placeholder item places itself just after the first item.

You can reproduce issue here:
https://codesandbox.io/s/vue-responsive-dash-wbgs8

Steps:

  1. Click "Add" button and add first item.
  2. Resize the added item.
  3. Click "Add" button to add another item.
    Note: See the space between first and second item.

Is there something I can do to influence this behaviour and remove this space?

Edit Mode Functionality

Hi @bensladden, is there a way to implement an edit mode functionality to this? Where by clicking a button, I can decide if the containers can be moved or resized and if it's in a viewing state, then I can't move or resize them?

Resize event on window resize

Hello! Please excuse me if this isn't the correct place to ask.

Dash item resizing event only occurs on user interaction.
Are there any events/methods to get resize data when the window is resized?

I'm drawing some svgs using d3.js https://d3js.org/, and I'm trying to pass in the dimensions of a dash item.
The results are great when resizing via handle and using the data from the resizing event - I'm hoping to somehow get the same effect when resizing the window.

Regards,

Matt

Not working on mobile

Hi guys, I loved your framework, really easy to use, but when I tried using on mobile or simulating mobile with chrome devtools it just doesn't work.

You guys are working on it? Because it's really a deal breaker now a days.

Possible Positioning error

Hi

I found a strange case where the positions of the dash-items are not where they are meant to be from the layout config.
see example

https://codesandbox.io/s/vue-responsive-dash-fhkwx?file=/src/App.vue

The box 2 should be at the top at y=0 however it is positioned at y=6
in code it is
items: [
{ id: "1", x: 6, y: 3, width: 6, height: 3 },
{ id: "2", x: 9, y: 0, width: 3, height: 3 },
{ id: "3", x: 0, y: 0, width: 8, height: 3 },
]

in debug it is
{"id":"2","x":9,"y":6,"top":386,"left":573,"width":3,"widthPx":178,"height":3,"heightPx":178,"draggable":true,"resizable":true},

There seems to be enough space at the top for it to fit.

I also found if i changed the order it seemed to fix it, e.g. following seems to work.

      items: [
        { id: "3", x: 0, y: 0, width: 8, height: 3 },
        { id: "1", x: 6, y: 3, width: 6, height: 3 },
        { id: "2", x: 9, y: 0, width: 3, height: 3 },
      ]

In my case the order is user defined so I can't control the order of the items, so this is an issue for me.

Hopefully you can find a fix.

Regards
Peter

Vue component definition causing duplicate vue instances

I'm not sure why I can't seen to get this component to work ... coping and pasting the example results in a nothingness .. inspecting the layout instance I noticed that is due to the breaking point always being null:

image

How is this breakpoint calculate and why it is null?

Autoplacing DashItems

I was wondering if there is a way to not pass the X and Y for the DashItem and the DashLayout should compute where it should be placed.

In my application I have several cards with diferente sizes and the user can add and remove them dynamicaly, If I could just append it to the "items" it would be awesome, in addition it would solve the problem for different breakpoints/"viewports sizes".

dlayouts model doesnt change

I have to get dlayout model to save, however there is no change in dlayout model after resize or move objects. By the way, if I change to debug mode, I can show changes as json. How to get dlayout model?

Doesn't appear to work on Windows

Hi, this project is exactly what I was looking for, but unfortunately your demo bugs out completely on my Windows machine. I've tried both Firefox and Chrome. It works perfectly on my Mac though.

Unknown custom element <layout>

I've copied and pasted the example code into a blank file in my vue project. I'm getting the warning:

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Also, none of the elements are getting shown. It's just a blank page.

How to hook a click, dblclick or contextmenu event to a dash-Item component?

Hello bensladden,
thank you very much for your continued effort in developing such a nice module.

I am trying to fire a dblclick event so that a configuration window opens up when the user double clicks on a dash-item.
So far I had no luck.
Is there any example I can use?
I am also trying to fire a click or a contextmenu event but nothink happens either.

Thank you very much for any help.

How to change the space between items

Hello,
is there any possibility to change the space between items.
For a specific application I would like to have the items to touch each other with no space in between.
I have seen that there is a 'margin' prop in the Dashboard but is seems not used.

Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.