GithubHelp home page GithubHelp logo

Comments (11)

38 avatar 38 commented on July 25, 2024

Stroke width is a newly added feature in 0.2.6

You should be able to use it as following:

LineSeries::new( ...., Into<ShapeStyle>::into(&RED).stroke_width(2))

from plotters.

serzhiio avatar serzhiio commented on July 25, 2024
error[E0277]: the trait bound `plotters::style::ShapeStyle: plotters::style::color::SimpleColor` is not satisfied
   --> src\scenes\instances\components\chart\mod.rs:186:17
    |
186 |                 &Into::<ShapeStyle>::into(&RED).stroke_width(2),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `plotters::style::color::SimpleColor` is not implemented for `plotters::style::ShapeStyle`
    |
    = note: required because of the requirements on the impl of `plotters::style::color::Color` for `plotters::style::ShapeStyle`
    = note: required because of the requirements on the impl of `std::convert::From<&plotters::style::ShapeStyle>` for `plotters::style::ShapeStyle`
    = note: required because of the requirements on the impl of `std::convert::Into<plotters::style::ShapeStyle>` for `&plotters::style::ShapeStyle`
    = note: required by `plotters::series::line_series::LineSeries::<Coord, I>::new`

from plotters.

38 avatar 38 commented on July 25, 2024

Remove the leading and sign would fix this.

Cause &impl Color can be converted to shape style. as long as you are passing a shape style anyway, you don't need to borrow.

from plotters.

serzhiio avatar serzhiio commented on July 25, 2024

bingo!

from plotters.

serzhiio avatar serzhiio commented on July 25, 2024

But in draw_line() func i'm still getting 1!

    fn draw_line<S: BackendStyle>(
        &mut self,
        from: BackendCoord,
        to: BackendCoord,
        style: &S,
    ) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
        if style.as_color().alpha() == 0.0 {
            return Ok(());
        }
        let stroke_width = style.stroke_width() as u8;

from plotters.

serzhiio avatar serzhiio commented on July 25, 2024

https://github.com/38/plotters/blob/e0219d9036360f5025f67def237305f03dd5a632/src/drawing/backend.rs#L37

from plotters.

38 avatar 38 commented on July 25, 2024

But in draw_line() func i'm still getting 1!

Nop, this is the default impelentation

https://github.com/38/plotters/blob/e0219d9036360f5025f67def237305f03dd5a632/src/drawing/backend.rs#L53

This is where it passes through

from plotters.

serzhiio avatar serzhiio commented on July 25, 2024

I see it, but i cant pull out custom stroke_width from BackendStyle struct.

from plotters.

serzhiio avatar serzhiio commented on July 25, 2024

Resolved, its working as expected. Sorry for your time.

from plotters.

38 avatar 38 commented on July 25, 2024

No problem. Let me know if you have other questions

from plotters.

jbowens avatar jbowens commented on July 25, 2024

I'm having trouble setting a stroke width as well. Does the wasm/canvas backend support setting a stroke width? That's the backend that I've been trying.

from plotters.

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.