yuankunzhang / charming

A visualization library for Rust
Apache License 2.0
1.85k stars 74 forks source link

Line smooth option as bool is not working as intended #83

Closed LukaOber closed 1 month ago

LukaOber commented 1 month ago

The smooth setter takes an input that can be converted into a f64. When giving the function a true it is converted to 1.0f64. This is a different result than I would expect. It should keep the bool. The chart with a smoothness of 1.0f64 looks very different to a chart with the smoothness of true.

let chart = Chart::new()
    .x_axis(
        Axis::new()
            .type_(AxisType::Category)
            .data(vec!["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]),
    )
    .y_axis(Axis::new().type_(AxisType::Value))
    .series(
        Line::new()
            .smooth(true)
            .data(vec![820, 932, 901, 934, 1290, 1330, 1320]),
    );

Will produce this chart option:

// cut for brevity
"series": [
    {
      "type": "line",
      "smooth": 1.0,
      "data": [
        820,
        932,
        901,
        934,
        1290,
        1330,
        1320
      ]
    }
  ]

But it should produce this:

// cut for brevity
"series": [
    {
      "type": "line",
      "smooth": true,
      "data": [
        820,
        932,
        901,
        934,
        1290,
        1330,
        1320
      ]
    }
  ]

If you want I can fix this issue.