apexcharts-card icon indicating copy to clipboard operation
apexcharts-card copied to clipboard

Chart appears with -0.0 on Y-axis

Open kaizersoje opened this issue 3 years ago • 4 comments

Checklist

  • [x] I updated the card to the latest version available
  • [x] I cleared the cache of my browser
  • [x] I verified that I'm really running the lastest version in my browser console
  • [x] I checked if there is another issue opened with the same problem

Describe the bug A clear and concise description of what the bug is. I have noticed that on one of the charts the 0 point is showing up as -0.0. However sometimes it appears 0.0

Version of the card Version: 1.8.2

To Reproduce This is the configuration I used:


apexcharts_card_templates:
  all_series_no_legend_value:
    all_series_config:
      show:
        legend_value: false

- type: custom:apexcharts-card
    config_templates:
      - all_series_no_legend_value
    apex_config:
      chart:
        height: 300px
      yaxis:
        tickAmount: 5
    all_series_config:
      type: column
      data_generator: |
        let now = start.getTime();
        const data = JSON.parse(entity.attributes.data);
        return data.map((entry) => {
          const lNow = now;
          now += 30 * 60 * 1000;
          return [lNow, entry];
        });
    color_list: ['ROYALBLUE', 'ORANGE']
    graph_span: 24h
    stacked: true
    span:
      start: day
      offset: -1d
    series:
      - entity: sensor.energy_grid_usage
        name: Grid
      - entity: sensor.energy_solar_feedin
        name: Solar Export

Screenshots If applicable, add screenshots to help explain your problem.

chart

Expected behavior A clear and concise description of what you expected to happen. I reckon it should show as 0.0

Desktop (please complete the following information):

  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] Version 89.0.4389.82

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

kaizersoje avatar Mar 08 '21 23:03 kaizersoje

Sound like an issue on ApexCharts, not much I can do unfortunately.

RomRider avatar Mar 09 '21 19:03 RomRider

Sound like an issue on ApexCharts, not much I can do unfortunately.

Ok, thanks.

kaizersoje avatar Mar 09 '21 21:03 kaizersoje

I think this is not -0.0. this is something -0.003. Real 0 position is a bit higher then "-0.0" I have same problem with stacked charts. I can manually set min/max with correct tickAmount. but this isn't good idea... we need something like "force zero tick".

Kirorus avatar Jun 21 '21 17:06 Kirorus

Ran into the same issue. It helps to set forceNiceScale: true in y-axis through apex_config.

i.e. in the OP:

   apex_config:
      yaxis:
        tickAmount: 5
        forceNiceScale: true

stefsmeets avatar Jul 26 '21 08:07 stefsmeets