JavaScript Two lined D3.js line chart, with one line starting at different position excel leader lines line chart,multiple lines line chart power

I am creating a Line Chart in D3.js with two lines. The second line needs to start (and be rendered) and at a later date than the first. The data I am using for the graph looks like this:

var data = [{
    date: "1-May-12",
    close: "58.13",
    open: "58.13"
}, {
    date: "30-Apr-12",
    close: "53.98",
    open: "53.98"
}, {
    date: "27-Apr-12",
    close: "67.00",
    open: "67.00"
}, {
    date: "26-Apr-12",
    close: 0,
    open: "89.70"
}, {
    date: "25-Apr-12",
    close: 0,
    open: "99.00"
}];

In my current example, both lines are plotted but the second line (close) is plotted at the bottom of the graph and then jumps to the third value. I need the line to start when there is data. I have tried changing the value from 0 to null without any success. How do I change the graph so the second line only starts when there is actual data?

See this JSFiddle for the example: https://jsfiddle.net/londonfed/hprd452q/4/

Thanks in advance.

Answer:1

You can define where the line is and isn't defined using defined(). For example to set the line as undefined when it is 0 (or less) you can use:

var valueline = d3.svg.line()
   .defined(function(d) {return d.close > 0})
   .x(function(d) { return x(d.date); })
   .y(function(d) { return y(d.close); });

This will cause the line not to draw anywhere d.close is <= 0.

Dos for defined() here: https://github.com/d3/d3-shape/blob/master/README.md#line_defined

Here's an updated Fiddle: https://jsfiddle.net/4hkLqn84/

Answer:2

I am using the jQuery Globalize library which uses cldr for internationalization. Before you can use any of the Globalize functions, you have to load the correct cldr-data and pass it to Globalize. ...

I am using the jQuery Globalize library which uses cldr for internationalization. Before you can use any of the Globalize functions, you have to load the correct cldr-data and pass it to Globalize. ...

I am new to CSS. Trying to align these input field validation tooltip this is fiddle: http://jsfiddle.net/fade3r5f/ can anyone help how can I do this.? I can able to move it to left and right but ...

I am new to CSS. Trying to align these input field validation tooltip this is fiddle: http://jsfiddle.net/fade3r5f/ can anyone help how can I do this.? I can able to move it to left and right but ...

How can I pass the site_id parameter to pageTitle from data ? .state('site', { url: "/site/:site_id", templateUrl: "views/site_detail.html", data: {pageTitle: 'Site :' + $scope.$...

How can I pass the site_id parameter to pageTitle from data ? .state('site', { url: "/site/:site_id", templateUrl: "views/site_detail.html", data: {pageTitle: 'Site :' + $scope.$...

  1. angularjs pass state parameter to controller
  2. angularjs pass state params
  3. angularjs pass state parameter
  4. angularjs state pass object
  5. angularjs pass data to state
  6. angularjs pass variable to state
  7. angularjs pass multiple parameters to state

I have an array model as below: nodes:[ { id: 1, label: 'label1'}, { id: 2, label: 'label2'}, { id: 3, label: 'label3'} ] I whant to get the label of node filtering by id I tried the next way, ...

I have an array model as below: nodes:[ { id: 1, label: 'label1'}, { id: 2, label: 'label2'}, { id: 3, label: 'label3'} ] I whant to get the label of node filtering by id I tried the next way, ...

  1. filter array objects javascript
  2. filter array objects angular 6
  3. filter array objects
  4. filter array objects js
  5. filter array objects swift
  6. filter array objects jquery
  7. filter array objects angularjs
  8. filter array objects lodash
  9. filter array objects angular2
  10. array filter objects php
  11. filter array of objects by property
  12. filter array of objects typescript
  13. filter array of objects javascript es6
  14. filter array of objects by property javascript
  15. filter array of objects javascript by key
  16. filter array of objects by key
  17. filter array of objects by key value
  18. filter array of objects javascript by value
  19. filter array of objects based on property
  20. filter array of objects javascript based on property