Comments (8)
There is a way. Create a scope function on your controller like the following
$scope.xAxisTickFormatFunction = function(){
return function(d){
return d3.time.format('%x')(new Date(d)); //uncomment for date format
}
}
Then in the directive element, assign the scope function to the xAxisTickFormat attribute. Like the following
xAxisTickFormat="xAxisTickFormatFunction()"
The directive assigns the function to the xAxis.tickFormat() call in nvd3/d3 behind the scenes.
Check out the lineChart.with.configuration.html as well.
Chris
from angularjs-nvd3-directives.
also, you can look at
http://cmaurer.github.io/angularjs-nvd3-directives/axis.formatting.html
Which is the documentation I am working on for formatting an axis. I still need to review it, etc before I 'publish' it. You can access it directly.
from angularjs-nvd3-directives.
Thanks for the swift answer! I am going to try right away.
from angularjs-nvd3-directives.
Cool. Let me know if you get stuck.
Chris
Sent from my iPhone
On Sep 19, 2013, at 4:17 AM, jnmoons [email protected] wrote:
Thanks for the swift answer! I am going to try right away.
—
Reply to this email directly or view it on GitHub.
from angularjs-nvd3-directives.
Also, let me know if I can close the issue/question.
Thanks,
Chris
From: jnmoons [email protected]
To: cmaurer/angularjs-nvd3-directives [email protected]
Cc: Christian Maurer [email protected]
Sent: Thursday, September 19, 2013 4:17 AM
Subject: Re: [angularjs-nvd3-directives] Show dates as dates (#18)
Thanks for the swift answer! I am going to try right away.
—
Reply to this email directly or view it on GitHub.
from angularjs-nvd3-directives.
@jnmoons - I am going to close this issue. If you need help, email me or open another one.
Thanks,
Chris
from angularjs-nvd3-directives.
I'm having problems getting this to display.
Here's my relevant code:
function myCtrl() {
$scope.chartTest = [
{
"key": "Series 1",
"values": [
[ "2014-01-15T00:00:00.000-08:00", 1], [ "2014-02-15T00:00:00.000-08:00", 2], [ "2014-03-15T00:00:00.000-08:00", 3]
]
}
];
$scope.xAxisTickFormatFunction = function() {
return function(d){
return d3.time.format('%B %Y')(new Date(d));
}
};
};
And my HTML:
<nvd3-line-chart
data="chartTest"
id="remedyExample"
yAxisTickFormat="yAxisTickFormatFunction()"
xAxisTickFormat="xAxisTickFormatFunction()"
width="550"
height="350"
showXAxis="true"
showYAxis="true"
showLegend="true">
<svg></svg>
</nvd3-line-chart>
And my output is a chart with dates displaying along the bottom, but they all say "December 1969."
I can open the console on the page and run d3.time.format('%B %Y')(new Date("2014-01-15T00:00:00.000-08:00"));
and it properly returns January 2014
.
What does d
represent in your $scope.xAxisTickFormatFunction()
? It seems like it isn't getting the data I'm trying to send to it.
Any help would be very much appreciated, I've been wrestling this for a couple days now.
from angularjs-nvd3-directives.
Switching the "2014-01-15T00:00:00.000-08:00" manually to milliseconds var foo = new Date("2014-01-15T00:00:00.000-08:00").getTime()
fixes the issue, but I'm not sure where to programatically change it.
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.