خرید بک لینک

Vote count: 0

My Bar chart has a gap where half the bar is between the x axis and y axis and I tried fixing this by putting blank data at the start and the end and this makes it so that the bars are not halfway on the axis, but there is still a unruly gap between the Y axis and the X axis. I would either like a way to move the Y axis alone to the right so that it meets the X axis or to find a way to remove the gap without putting blank data. Either Is fine for now. Happy Debugging!

   function InitPieChart(strings,selectedCity){
        // cities.forEach(function(city){
            if(selectedCity==""){
                DataForPieGraph=[{Name:"",data:0}];
                    strings.forEach(function(string){
                        cities.forEach(function(city){
                             DataForPieGraph.push({Name:string ,data:(test.SumHelper(Projectsall, city, string))});
                        })
                    })
            }
            DataForPieGraph.push({Name:" ",data:0});
            console.log(DataForPieGraph);
    var ndx           = crossfilter(DataForPieGraph),
    nameDim  = ndx.dimension(function(d) {retu d.Name;}),
    spendPerName = nameDim.group().reduceSum(function(d) {retu +d.data;});

          // CityChart
          //  .width(200).height(176)
          //   .dimension(nameDim)
          //   .group(spendPerName)
          //   .ierRadius(30)

          //   .label(function(d) { retu d.data.value})
          //   .legend(dc.legend().x(0).y(0).itemHeight(13).gap(5));
          //   CityChart.render()

        // cities.forEach(function(city){
          ProjectChart
            .width(768)
            .elasticX(true)
            .xAxisPadding(50)
            .centerBar(true)
            // .margins({top: 10, right: 50, bottom: 00, left: -10})
            .height(380)
            .x(d3.scale.ordinal().domain(["","Active","Pending","Value.Visits"," "]))
            .xUnits(dc.units.ordinal)
            .brushOn(false)
            .yAxisLabel('Amount')
            .dimension(nameDim)
            .colors(["#097DBC","#049FD9","#C4D6ED"])
            .colorAccessor(function(d, i){retu i;})
            .xAxisPadding(50)
            // .colors(d3.scale.ordinal().domain(["Active Projects", "Pending Projects","Visits"])
                            // .range(["#097DBC","#049FD9","#64BBE3"]))
            // .barPadding(0.1)
            // .outerPadding(0.05)

            .group(spendPerName);
            ProjectChart.render();
           ProjectChart.renderlet(function(chart){

                var barsData = [];
                var bars = chart.selectAll('.bar').each(function(d) { barsData.push(d); });

                //Remove old values (if found)
                d3.select(bars[0][0].parentNode).select('#inline-labels').remove();
                //Create group for labels 
                var gLabels = d3.select(bars[0][0].parentNode).append('g').attr('id','inline-labels');

                for (var i = bars[0].length - 1; i >= 0; i--) {

                    var b = bars[0][i];
                    //Only create label if bar height is tall enough
                    if (+b.getAttribute('height') < 18&&+b.getAttribute('height')!=0){

                    gLabels
                        .append("text")
                        .text(barsData[i].data.value)
                        .attr('x', +b.getAttribute('x') + (b.getAttribute('width')/2) )
                        .attr('y', +b.getAttribute('y')-1)
                        .attr('text-anchor', 'middle')
                        .attr('fill', 'black');
                    }else if(+b.getAttribute('height')!=0){
                        gLabels
                        .append("text")
                        .text(barsData[i].data.value)
                        .attr('x', +b.getAttribute('x') + (b.getAttribute('width')/2) )
                        .attr('y', +b.getAttribute('y')+18)
                        .attr('text-anchor', 'middle')
                        .attr('fill', 'black');
                    }
                }

            })
    }

asked 13 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 13 مرداد 1395 ساعت: 0:19

صفحه بندی