Note that there are some explanatory texts on larger screens.

plurals
  1. PONVD3 Line Plus Bar Chart timeline
    primarykey
    data
    text
    <p>I have to add proper timeline to "Line Plus Bar Chart", meaning dates must be spread across x-axis equally. For example AAPL dividend history. <img src="https://i.stack.imgur.com/JxD11.png" alt="enter image description here"> And since AAPL didn't make payment between 1995 and 2012, there should be blank space. So I need x-axis to be spread according to the first and the last date. Something like this: <img src="https://i.stack.imgur.com/4tqGa.png" alt="enter image description here"> Is there a way to show x-axis fixed on real dates, ignoring data?</p> <p>or do I need to add 0 values to my dividend_set? This is my data for dividend_set.</p> <pre><code>&lt;script type="text/javascript"&gt; function exampleData() { return [ { "key" : "Dividends" , "bar": true, "values" : [ [ 547707600000 , 0.015 ] , [ 555570000000 , 0.015 ] , [ 564127200000 , 0.02 ] , [ 571644000000 , 0.02 ] , [ 579762000000 , 0.02 ] , [ 587624400000 , 0.02 ] , [ 596095200000 , 0.025 ] , [ 603698400000 , 0.025 ] , [ 611816400000 , 0.025 ] , [ 619678800000 , 0.025 ] , [ 627285600000 , 0.0275 ] , [ 635148000000 , 0.0275 ] , [ 643266000000 , 0.0275 ] , [ 651128400000 , 0.0275 ] , [ 658735200000 , 0.03 ] , [ 666597600000 , 0.03 ] , [ 674715600000 , 0.03 ] , [ 682578000000 , 0.03 ] , [ 690444000000 , 0.03 ] , [ 698047200000 , 0.03 ] , [ 707374800000 , 0.03 ] , [ 714027600000 , 0.03 ] , [ 723103200000 , 0.03 ] , [ 729496800000 , 0.03 ] , [ 738565200000 , 0.03 ] , [ 745477200000 , 0.03 ] , [ 753688800000 , 0.03 ] , [ 760600800000 , 0.03 ] , [ 770014800000 , 0.03 ] , [ 776926800000 , 0.03 ] , [ 785138400000 , 0.03 ] , [ 792655200000 , 0.03 ] , [ 801464400000 , 0.03 ] , [ 808549200000 , 0.03 ] , [ 816933600000 , 0.03 ] , [ 1344488400000 , 2.65 ] , [ 1352268000000 , 2.65 ] , [ 1360216800000 , 2.65 ] ] } , { "key" : "Dividends together" , "values" : [ [ 547707600000 , 0.015 ] , [ 555570000000 , 0.03 ] , [ 564127200000 , 0.05 ] , [ 571644000000 , 0.07 ] , [ 579762000000 , 0.09 ] , [ 587624400000 , 0.11 ] , [ 596095200000 , 0.135 ] , [ 603698400000 , 0.16 ] , [ 611816400000 , 0.185 ] , [ 619678800000 , 0.21 ] , [ 627285600000 , 0.2375 ] , [ 635148000000 , 0.265 ] , [ 643266000000 , 0.2925 ] , [ 651128400000 , 0.32 ] , [ 658735200000 , 0.35 ] , [ 666597600000 , 0.38 ] , [ 674715600000 , 0.41 ] , [ 682578000000 , 0.44 ] , [ 690444000000 , 0.47 ] , [ 698047200000 , 0.5 ] , [ 707374800000 , 0.53 ] , [ 714027600000 , 0.56 ] , [ 723103200000 , 0.59 ] , [ 729496800000 , 0.62 ] , [ 738565200000 , 0.65 ] , [ 745477200000 , 0.68 ] , [ 753688800000 , 0.71 ] , [ 760600800000 , 0.74 ] , [ 770014800000 , 0.77 ] , [ 776926800000 , 0.8 ] , [ 785138400000 , 0.83 ] , [ 792655200000 , 0.86 ] , [ 801464400000 , 0.89 ] , [ 808549200000 , 0.92 ] , [ 816933600000 , 0.95 ] , [ 1344488400000 , 3.6 ] , [ 1352268000000 , 6.25 ] , [ 1360216800000 , 8.9 ] ] } ].map(function(series) { series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } }); return series; }); } &lt;/script&gt; </code></pre> <p>This is my d3.js/nv code:</p> <pre><code>nv.addGraph(function() { var testdata = exampleData(), chart = nv.models.linePlusBarChart() .margin({top: 30, right: 70, bottom: 50, left: 70}) .x(function(d,i) { return i }) .color(d3.scale.category10().range()); chart.xAxis.tickFormat(function(d) { var dx = testdata[0].values[d] &amp;&amp; testdata[0].values[d].x || 0; return d3.time.format('%x')(new Date(dx)) }); chart.y1Axis .tickFormat(d3.format(',05f')); chart.y2Axis .tickFormat(function(d) { return '$' + d3.format(',05f')(d) }); chart.bars.forceY([0]); chart.lines.forceY([0]); d3.select('#chart svg') .datum(exampleData()) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); return chart; }); </code></pre> <p>I guess if it cant be done by some NDV3 function, I must calculate what is average interval between dividends and then check, if there is date within that range and if not, I will add similar date interval with 0 dividend amount. Or what would be the best way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload