Comments (18)
from angularjs-nvd3-directives.
@sodoku That seems messed up. Let me take a look.
from angularjs-nvd3-directives.
Thanks for your fast response. Any findings what the problem is allready?
from angularjs-nvd3-directives.
It's the code that was put in to not need an id attribute. If it doesn't see an id attribute it creates one. That doesn't work so well for existing charts. Since d3 makes heavy use of selectors, being able to select the right chart is essential. I haven't tested it, but I suspect that if you added a unique id attr to the directive, it would work.
from angularjs-nvd3-directives.
@sodoku
I have been looking at this for a little while. I don't have any smoking guns. What is weird is that if you reverse the data, it works fine. If you start with no data, and the 'clearData()' method adds data, it looks good.
So I am thinking, at this point, it is somewhere in the nvd3 / d3 code, or how I am calling it. I will continue to dig into it.
Chris
from angularjs-nvd3-directives.
@cmaurer thanks you very much for digging into it!
from angularjs-nvd3-directives.
Hello,
I had the same problem. You can find similar problem in nvd3 : novus/nvd3#349
To prevent this problem and waiting a real solution, I changed the "checkElementID" function to this one :
function checkElementID(scope, attrs, element, chart, data) { 'use strict'; var dataAttributeChartID; //randomly generated if id attribute doesn't exist if(!attrs.id){ dataAttributeChartID = "chartid" + Math.floor(Math.random()*1000000001); angular.element(element).attr('data-chartid', dataAttributeChartID ); //if an id is not supplied, create a random id. if(d3.select('[data-chartid=' + dataAttributeChartID + '] svg').empty()) { d3.select('[data-chartid=' + dataAttributeChartID + ']').append('svg') .attr('height', scope.height) .attr('width', scope.width) .datum(data) .transition().duration((attrs.transitionduration === undefined ? 250 : (+attrs.transitionduration))) .call(chart); } else { d3.select('[data-chartid=' + dataAttributeChartID + '] svg') .attr('height', scope.height) .attr('width', scope.width) .datum(data) .transition().duration((attrs.transitionduration === undefined ? 250 : (+attrs.transitionduration))) .call(chart); } } else { if(angular.isArray(data) && data.length == 0){ d3.select('#' + attrs.id + ' svg').remove(); } if(d3.select('#' + attrs.id + ' svg').empty()) { d3.select('#' + attrs.id) .append('svg'); } d3.select('#' + attrs.id + ' svg') .attr('height', scope.height) .attr('width', scope.width) .datum(data) .transition().duration((attrs.transitionduration === undefined ? 250 : (+attrs.transitionduration))) .call(chart); } }
The solution remove the svg graph if data is empty.
I can create a pull request if you want.
from angularjs-nvd3-directives.
@julienmeyer
Please create a pull request. I would appreciate it.
Thanks,
Chris
from angularjs-nvd3-directives.
Similar issue here... my workaround was simply something like this:
if (data.length === 0) {
d3.select(_.first(element)).select('.nvd3').remove();
}
This lets me clear the "old" chart if my new data is empty.
from angularjs-nvd3-directives.
@julienmeyer, when do you think you will create the pull request?
from angularjs-nvd3-directives.
Today ;-)
Sorry for the time it took...
#148
from angularjs-nvd3-directives.
@julienmeyer No problem. I have been unable to focus recently as well (family, job, etc).
from angularjs-nvd3-directives.
pull request #148 only fixes the issue where the element has an "id" attribute. I recently opened pull request #205 for another reason but I believe that I have fixed this problem in that pull request.
from angularjs-nvd3-directives.
Hello, is this issue resolved in any way? Even if I add an 'id' to the tag, my charts stop refreshing once I reset the data. I am using the latest version available via Bower. Any update appreciated. Thank you.
from angularjs-nvd3-directives.
@kunickiaj solution is a good workaround. How I use it:
.directive('myCoolChart', function () {
return {
restrict: 'A',
replace: true,
templateUrl: 'widgets/customChart.html',
controller: function ($scope) {
$scope.$watch('mydata', function(newValues) {
if (!newValues) {
$scope.chartData = [{'key': 'MyKey', 'values': []}]; // Empty -> No Data
} else {
$scope.chartData = [{'key': 'MyKey', 'values': newValues}];
}
});
link: function(scope, el, attr) {
scope.$watch('mydata', function(newValues) {
if (!newValues) {
d3.select(_.first(el)).select('.nvd3').remove(); // remove old graph
}
})
}
from angularjs-nvd3-directives.
Same problem. Spent 3 hours pulling my hair from the top of my scalp with this, until I found this issue thread
from angularjs-nvd3-directives.
is apply() going to resolve this ? ^^''''
from angularjs-nvd3-directives.
@julienmeyer in my case data is update not empty any trick for updated data ?
from angularjs-nvd3-directives.
Related Issues (20)
- how to i18n
- Custom data field names for sunburst..?
- How to achieve horizontal interactive guide line in nvd3 charts
- Need a vertical scroll in multiBarHorizontalChart if no. of bars increases
- How to i get data when iam click on pie chart HOT 2
- Discretebar Chart HOT 1
- Is there a way to save the graph and/or all its data to an xml or xmls ?
- TypeError: nv.dispatch.render_start is not a function HOT 2
- Pie Chart Label Lines with angular-nvd3
- Cannot read property 'disabled' of undefined
- Wrap long axis labels
- TypeError: nv.dispatch.render_start is not a function HOT 1
- Tooltip Not Hide while clicking outside of chart element in IPAD Devices
- Gradient color
- Format of focus chart x axis in "lineWithFocusChart" HOT 2
- Interactive Guideline Not showing on all the data points
- Fixed Labels on xAxis
- When selecting/deselecting legends with multi lines on line chart the lines start showing incorrect colors
- Cannot output data to another component using angular 2 custom event @Output()
- Discrete Bar chart tooltip customize
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angularjs-nvd3-directives.