Coder Social home page Coder Social logo

Comments (10)

cmaurer avatar cmaurer commented on June 10, 2024

Yes,
For the individual axis elements use d3.format and a formatFunction to format the percentage.
https://github.com/mbostock/d3/wiki/Formatting#wiki-d3_format
percentage ("%") - like fixed, but multiply by 100 and suffix with "%".

For the overall axis label there are a couple of attributes that handle that, xAxisLabel, yAxisLabel.

Post to plnkr (or something else), if you need help.

Chris

from angularjs-nvd3-directives.

dagumak avatar dagumak commented on June 10, 2024

Am I doing this wrong? The chart is showing up nicely except for the formatting of the y-axis labels.

$scope.yAxisLabelFunction = () ->
   d3.format('%')

yaxislabel="yAxisLabelFunction()"

from angularjs-nvd3-directives.

cmaurer avatar cmaurer commented on June 10, 2024

Are you trying to format a value, or are you trying to show a '%' sign?

If you are trying to format a data value you need to do something like the following:

            $scope.yAxisLabelFunction = function(){
                return function(d){
                    return d3.format('%')(d);
                }
            }

If you are trying to show a '%' sign, just return the '%' sign.

from angularjs-nvd3-directives.

dagumak avatar dagumak commented on June 10, 2024

I'm trying to format the labels of the y-axis. For example, in the first graph on this page: http://cmaurer.github.io/angularjs-nvd3-directives/multi.bar.chart.html

I want 9.3 to be a percentage with the % symbol and without the decimal.

from angularjs-nvd3-directives.

cmaurer avatar cmaurer commented on June 10, 2024

Ok, thats what I thought. Give me a sec.

from angularjs-nvd3-directives.

cmaurer avatar cmaurer commented on June 10, 2024

Try this.

  $scope.yAxisFormatFunction = function(){
                return function(d){
                    return d3.format('%')(d);
                }
            }
<div ng-controller="ExampleCtrl">
    <nvd3-multi-bar-chart
            data="exampleData"
            showYAxis="true"
            id="exampleId"
            yAxisTickFormat="yAxisFormatFunction()">
        <svg></svg>
    </nvd3-multi-bar-chart>
</div>

from angularjs-nvd3-directives.

dagumak avatar dagumak commented on June 10, 2024

Hey Chris! That worked! Thank you very much!

from angularjs-nvd3-directives.

cmaurer avatar cmaurer commented on June 10, 2024

No problem. Glad you got it going.

Chris

from angularjs-nvd3-directives.

udaykanth3 avatar udaykanth3 commented on June 10, 2024

how to display values(x,y) on the line chart graph using NVD3.. directly on the line chart i need to display ?? if possible reply me ...

from angularjs-nvd3-directives.

tilluran006 avatar tilluran006 commented on June 10, 2024

Its straight forward
add
.showValues(true)
in you code

from angularjs-nvd3-directives.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.