GithubHelp home page GithubHelp logo

Comments (3)

zcei avatar zcei commented on June 26, 2024

Hi Bruno,

first, it would be great if you could wrap your code into three backticks (`) - it's more comfortable to read.

The ChartDataLayer still got some bugs (e.g. dynamic color binding), so as a new fan of DVF I'll probably start there for more enhancements. Eventually your problems will be addressed there, too.

As a test you could try using this snippet from the Wiki:

var legendControl = new L.Control.Legend();

legendControl.addTo(map);

Is there still no radius legend?

Best regards,
Stephan

from leaflet-dvf.

sfairgrieve avatar sfairgrieve commented on June 26, 2024

Bruno,

At the moment, there's no built in way to make the PieChartDataLayer automatically display the radius legend in addition to the category legend. As Stephan was mentioning, there's still a lot of work to be done there. I haven't tried this, but for now, you could implement this yourself by passing in a getLegend option to PieChartDataLayer. In the getLegend method, you could call the code for generating the pie chart legend as well as the normal DataLayer legend code. Here's some code that might work (completely untested):

var pieChartLayer = new L.PieChartDataLayer(data, {
     ...
     getLegend: function (legendOptions) {
          // Call ChartDataLayer _getLegend
          var chartLegend = L.ChartDataLayer.prototype._getLegend.call(this, legendOptions);

          // Add code for calling DataLayer _getLegend
          var dataLayerLegend = L.DataLayer.prototype._getLegend.call(this, legendOptions);

          // Combine legend HTML as necessary
          var $legend = $('<div></div>');
          $legend.append(chartLegend);
          $legend.append(dataLayerLegend);

          return $legend.wrap('<div/>').parent().html();
     }
});

I'll include a fix in the next push that will make this work, but let me know if the temporary workaround makes sense and actually works.

Thanks,

Scott

from leaflet-dvf.

brunodeprez avatar brunodeprez commented on June 26, 2024

Hi Scott,

your completely untested code worked perfectly without any modifications!

untitled

Thanks a lot!

Bruno

from leaflet-dvf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.