0

enter image description herefor this example http://jsfiddle.net/5D5eD/8/. How to increase the Y-axis above X-axis also ?

 main.append('g')
.attr('transform', 'translate(0,0)')
.attr('class', 'main axis date')
.call(yAxis)

what change should I make in this line .attr('transform', 'translate(0,0)') ?

user3438326
  • 89
  • 2
  • 10

1 Answers1

1

In order to do this, you need to run the code for plotting the chart again (minus the line plotting part) on another g element that has been translated. In order to do this, it's easiest to wrap the part that draws the graph in a function and call that twice.

Complete demo here.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
  • Lars I would like to add this projection http://bl.ocks.org/mbostock/3734327 to the chart on the top, while the chart at the bottom remains same. Can you guide me how to achieve this ? – user3438326 Mar 30 '14 at 03:56
  • Basically I want to get something like this http://www.d3noob.org/2013/03/a-simple-d3js-map-explained.html in place of the chart on the top. – user3438326 Mar 30 '14 at 04:00
  • Just don't call the function I've created twice on the different container elements but add the chart you want to the top. – Lars Kotthoff Mar 30 '14 at 12:22
  • I am able to add the chart http://bl.ocks.org/mbostock/3734327 Lars. But the datapoints must be visible on the chart too. How do I get this ? – user3438326 Mar 30 '14 at 12:35
  • Yes Lars I have seen this tutorial. But in my case I want the background of chart on top http://jsfiddle.net/5D5eD/18/ to be http://bl.ocks.org/mbostock/3734327. Or can I use an image in the background using css ? – user3438326 Mar 30 '14 at 13:37
  • You can do both. [This question](http://stackoverflow.com/questions/20987535/plotting-points-on-a-map-with-d3) may help. – Lars Kotthoff Mar 30 '14 at 13:44
  • File not found Lars, the bl.ocks.org link not working – user3438326 Mar 30 '14 at 13:52
  • Well [here](http://stackoverflow.com/questions/15769909/d3-js-plotting-points-on-zoomable-clickable-map) is another question about the same thing. There are lots more you can find on google/SO. – Lars Kotthoff Mar 30 '14 at 14:04