Coder Social home page Coder Social logo

Comments (6)

Raruto avatar Raruto commented on June 8, 2024

Hi @hupe13,

if I toggle all chart legend filter off, the polyline is black. Example.

It should be the intended behavior (somehow related to: #235).

If I comment out these lines

if (!this._chartEnabled) {
this._chart._hideDiagramIndicator();
this._marker.remove();
}

it works for me too.

Actually, the following should be the real cause:

// toggle layer visibility on empty chart
this._layers.eachLayer(layer => _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));

Your example works as expected.

Probably not implemented on canvas layers:

where CSS rules must be transposed into JS code, eg: L.Control.Elevation::_fixCanvasPaths()

👋 Raruto

from leaflet-elevation.

hupe13 avatar hupe13 commented on June 8, 2024

Hi Raruto,

after setting map.options.preferCanvas = true; it works now.

Thank you very much.

from leaflet-elevation.

hupe13 avatar hupe13 commented on June 8, 2024

There are many (other) problems with setting map.options.preferCanvas = true; in my WordPress plugin.

Actually, the following should be the real cause:

// toggle layer visibility on empty chart
this._layers.eachLayer(layer => _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));

Yes, it should be:

// toggle layer visibility on empty chart
this._layers.eachLayer(layer => layer.getElement && this._chartEnabled && this.options.polyline.className && _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));

`

from leaflet-elevation.

Raruto avatar Raruto commented on June 8, 2024

@hupe13 umph, some additional code explanation would help (it's somewhat a cryptic condition).

Also, if you feel you have the time: 👉 gifcap.dev (just to show the before/after to others).

👋 Raruto

from leaflet-elevation.

hupe13 avatar hupe13 commented on June 8, 2024

The problem in my first post was about the black polyline when all legend filters are turned off. You told me two possibilities to solve the problem:

  • setting preferCanvas: true
  • the line 913 in /src/control.js

First, I set map.options.preferCanvas = true; and it seemed to work. Today I know, it works with the default theme colors only. I have some options in my WordPress plugin that allow to change the colors. And if the user does this, this solution does not work. So I analyzed the line 913 and I found the solution above. I changed this corresponding line in my repository. Additionally I must set preferCanvas to false and now it works for non default theme colors also.

from leaflet-elevation.

hupe13 avatar hupe13 commented on June 8, 2024

Hi Raruto,

I changed this:

this._layers.eachLayer(layer => _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));

to

 this._layers.eachLayer(layer => layer.getElement && this._chartEnabled && this.options.polyline.className && _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));

I tested it with your example using custom colors. You can see, it works. Toggle Altitude on and off.

from leaflet-elevation.

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.