Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

how to display the tooltip #59

Closed
jadhavpamu2020 opened this issue Apr 5, 2014 · 1 comment
Closed

how to display the tooltip #59

jadhavpamu2020 opened this issue Apr 5, 2014 · 1 comment

Comments

@jadhavpamu2020
Copy link

i am using django framework for displaying graph

    {% extends "base.html" %}
    {% load staticfiles %}
       {% block content %}
     <head>
    <link href="{% static 'css/dc.css' %}"  rel="stylesheet" media="screen">
    </head>
    <body>
           <div class="container" style="margin-top: 140px">

           <div class="col-lg-4" id="test">

           </div>

            <div class="col-lg-4" id="test1">

            </div>

    <script type="text/javascript" src="{% static 'js/d3.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/crossfilter.js' %}"></script>
    <script type="text/javascript"  src="{% static 'js/dc.js' %}"></script>
    <script type="text/javascript"  src="{% static 'js/bootstrap.min.js' %}"></script>

    <script type="text/javascript">

     var chart = dc.pieChart("#test");
     var spenderRowChart = dc.rowChart("#test1");

     d3.csv("{% static 'sampledata/pramod.csv' %}", function(error, experiments) {

      experiments.forEach(function(x) {
       x.Name = x.Name;
        x.Party = x.Party;
        x.Gender = x.Gender;



      });

      var ndx  = crossfilter(experiments),

      GenderDimension = ndx.dimension(function(d) {return d.Gender;});
      spendPerName = GenderDimension.group();
      PartyDimension = ndx.dimension(function(d) {return d.Party;});
      PartyPerName= PartyDimension.group().reduceCount();


      // tooltips for row chart
      var tip = d3.tip()
          .attr('class', 'd3-tip')
          .offset([-10, 0])
          .html(function (d) { return "<span style='color: #f0027f'>" +  d.key + "</span> : "  + numberFormat(d.value); });
      chart
        .width(200)
        .height(200)
        .dimension(GenderDimension)
        .group(spendPerName)
        .innerRadius(50);

      spenderRowChart
        .width(350).height(900)
        .dimension(PartyDimension)
        .group(PartyPerName)
        .label(function (d) { return d.key })
        .title(function (d) { return d.value })
        .ordering(function(d) { return -d.value })
        .elasticX(true);

      chart.render();
      spenderRowChart.render();

      d3.selectAll("#test1").call(tip);
            d3.selectAll("#test1").on('mouseover', tip.show)
                .on('mouseout', tip.hide);


    });

    </script>
            </body>
    {% endblock %}
@caged
Copy link
Owner

caged commented Jun 6, 2014

A little late, but see the examples: https://github.com/Caged/d3-tip/tree/master/examples. Looks like you might be missing chart.call(tip) assuming chart is the d3 SVG element.

@caged caged closed this as completed Jun 6, 2014
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

2 participants