question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

<rect> attribute width: A negative value is not valid.

See original GitHub issue

Hi, I’m using Apexcharts in a Vue 2 project and currently calling the render() method within the component mounted() method. Now I get the two charts to render however it only displays on hot-reloading after saving new changes to a file. Not when the page hard-reloads.

I receive this error when the page with the charts loads from a page refresh:

apexcharts.min.js?2227:1 Error: <rect> attribute width: A negative value is not valid. ("-2.45")

this is my markup:

<div>
   <div ref="linechart"></div>
   <div ref="barchart"></div>
</div>

Here is what my chart data looks like:

data: () => {
    return {
      chartOne: {
        chart: {
          type: 'line',
          height: 380
        },
        stroke: {
          width: 3,
          curve: 'smooth'
        },
        series: [{
          name: 'sales',
          data: [ 30, 40, 35, 50, 49, 60, 70, 91, 125, 150 ]
        }],
        xaxis: {
          categories: [ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ]
        }
      },
      chartTwo: {
        chart: {
          type: 'bar',
          height: 380
        },
        series: [{
          name: 'sales',
          data: [ 30, 40, 35, 50, 49, 60, 70, 91, 125, 150 ]
        }],
        xaxis: {
          categories: [ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ]
        }
      }
    }

Here is what my mounted() function looks like:

let chart = new ApexCharts(this.$refs.linechart, this.chartOne)
    chart.render()
let barchart = new ApexCharts(this.$refs.barchart, this.chartTwo)
    barchart.render()

Any idea what’s happening here? I’m so confused what’s causing this error

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
junedchhipacommented, Aug 10, 2018

Thanks for the feedback. I agree examples are essential as the vue-apex docs are currently lacking a lot of details. I will add more information in README as well as create a page dedicated just for vue.js integration.

1reaction
junedchhipacommented, Aug 10, 2018

@availit Released the Vue.js version https://github.com/apexcharts/vue-apexcharts Let me know if the problem exists in this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: <rect> attribute width: A negative value is not valid. (" ...
I am using https://www.amcharts.com/demos/multiple-value-axes/. ... Error: <rect> attribute width: A negative value is not valid.
Read more >
D3.js Error: <rect> attribute width: A negative value is not ...
When I close a page in my app, I get this error "Error: attribute width: A negative value is not valid. ("-100")" in...
Read more >
Error: <rect> attribute width: A negative value is not valid
Hi,. On responsive plots, when the width is narrowed too much, an error is triggered with the message: Error: <rect> attribute width: A...
Read more >
How to Debug Error: Invalid negative value for <rect> attrib
Hello. I keep getting this error in the console: Error: Invalid negative value for <rect> attribute width="-2"
Read more >
Error: Invalid negative value for <rect> attribute width="-1"
Hi, i want to use a gantt chart to build a timeline to display some response time but i have an error in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found