Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Numeric range for the x-axis #92

Closed
audy opened this issue Apr 16, 2014 · 16 comments
Closed

Numeric range for the x-axis #92

audy opened this issue Apr 16, 2014 · 16 comments
Assignees

Comments

@audy
Copy link

audy commented Apr 16, 2014

Is it possible to create a Timeline with a plain numeric range for the x-axis?

@josdejong
Copy link
Contributor

Not yet. We are about to implement a line chart in the timeline though, having an horizontal a time axis and a vertical number axis. When we do that, it is a little step to just support two types of axis (Dates and Numbers), and support them both horizontally and vertically.

@zuniga7
Copy link

zuniga7 commented Dec 3, 2014

Has this feature been implemented yet?

@AlexDM0
Copy link
Contributor

AlexDM0 commented Dec 3, 2014

No, not yet. I also don't expect to see this before the end of the year. If you were referring to the line chart, that is available but also only for time data.

Regards,

Alex

@AlexDM0
Copy link
Contributor

AlexDM0 commented Jan 9, 2015

Hi,

Over the last year a lot of feature requests have been made. We have just introduced our new website which has a list of the requested features. We have placed this request on that list.

The list can be found here:
http://visjs.org/featureRequests.html

An explaination of the new system can be found here:
http://visjs.org/blog.html#New\ website\ for\ vis.js!

I would like to stress that this does not mean we abandon this request. Discussion here will continue if needed on this feature but we will close it to keep our Github issue page more of a bug-todo list.

Future feature requests will still be made here and then added to the website by us.

Regards,

Alex

@marxjb
Copy link

marxjb commented Nov 3, 2015

Hi,
the doc says "Date or number or string or Moment" for start/end. Does that imply we can use "arbitrary" numbers now as start/end now or is number just another expression for time in ms?

@josdejong
Copy link
Contributor

number as date expects a unix timestamp in milliseconds, like 1446586258426 (i.e. new Date().getTime()).

@mojoaxel mojoaxel changed the title Timeline w/ non DateTime index Numeric range for the x-axis Oct 24, 2016
@mojoaxel
Copy link
Member

This is propably a duplicate of #455 and should be fixed together.

@mojoaxel
Copy link
Member

Reopening as Feature-Request issue (see #2114).
Everybody: Please feel free to implement this!

@mojoaxel mojoaxel reopened this Oct 24, 2016
@sawatsky
Copy link

This would be highly helpful! I'm currently providing arbitrary DateTime data, hiding the x-axis with CSS, and using labels to represent a new x-axis. This feature would save me so much hassle!

@yotamberk yotamberk assigned yotamberk and unassigned yotamberk Oct 26, 2016
@yotamberk
Copy link
Contributor

Hi @sawatsky , are you able to pick up this feature?

@sawatsky
Copy link

@yotamberk I'd love to if I had the time. Unfortunately, I am completely swamped with work! I'm the only frontend developer working on a new project for network simulations.

@mojoaxel mojoaxel added the MAJOR MAJOR change in semantic versioning label Nov 3, 2016
@yotamberk yotamberk removed the MAJOR MAJOR change in semantic versioning label Dec 8, 2016
@yotamberk
Copy link
Contributor

@sawatsky & @audy I've managed to accomplish this with the current develop branch using the options.format with the next function:

var options = {
    start: new Date(0),
    end: new Date(100),
    min: new Date(0),
    format: {
      minorLabels: function(date, scale, step) {
        switch (scale) {
          case 'millisecond':
            return new Date(date).getTime() + "ms";
          case 'second':
            var seconds = Math.round(new Date(date).getTime() / 1000);
            return seconds + "s";
          case 'minute':
            var minutes = Math.round(new Date(date).getTime() / 1000 * 60);
            return minutes + "m";
         ............................ and so on ..........................
      }
    }
  };

You can change how the label will be presented. The above is a simple example.

I'm closing this issue. If this doesn't fulfill your needs, please reopen and elaborate what is missing.

@yotamberk yotamberk self-assigned this Dec 8, 2016
@mojoaxel
Copy link
Member

mojoaxel commented Dec 13, 2016

@yotamberk In the context of the timeline it might be enough to just show numbers instead of dates. But in the graph-2D a real number-scale is still needed. See #455

@jcc10
Copy link

jcc10 commented Aug 5, 2018

Dear future people, since it was never clearly stated here is the solution:


In the options of the timeline set the following:

options = {
    format: {
      minorLabels: function(date,scale,step) {
        // must have a space otherwise it will get mad.
        return new Date(date).getTime() + "";
      },
      majorLabels: function(date,scale,step) {
        // must have a space otherwise it will get mad.
        return new Date(date).getTime() + "";
      }
    },
    timeAxis:{scale:'millisecond'}
}

Then each timeline item can be like so:

{id: 4, content: 'item 4', start: 16, end: 19}


You are welcome future people. (probably future me.)

... This should really get it's own example.

@GaneshNimkar
Copy link

Not yet. We are about to implement a line chart in the timeline though, having an horizontal a time axis and a vertical number axis. When we do that, it is a little step to just support two types of axis (Dates and Numbers), and support them both horizontally and vertically.

Has this feature implemented, I have the same requirement of plain numeric series on x-axis

@GaneshNimkar
Copy link

var options = {
    start: new Date(0),
    end: new Date(100),
    min: new Date(0),
    format: {
      minorLabels: function(date, scale, step) {
        switch (scale) {
          case 'millisecond':
            return new Date(date).getTime() + "ms";
          case 'second':
            var seconds = Math.round(new Date(date).getTime() / 1000);
            return seconds + "s";
          case 'minute':
            var minutes = Math.round(new Date(date).getTime() / 1000 * 60);
            return minutes + "m";
         ............................ and so on ..........................
      }
    }
  };

Thank you so much this code solve my biggest problem...

:)

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

No branches or pull requests

10 participants