2013-06-21 3 views
5

nvd3의 개별 막대 차트에서 y 축 눈금 레이블을 제거하려고합니다.nvd3 : 개별 막대 차트에서 y 축 눈금 레이블 제거

이미 nvd3 소스를 조사했지만 변경할 수있는 확실한 기능을 찾을 수 없습니다. 누구든지 해결책을 가르쳐 줄 수 있습니까?

업데이트 : 코드

function Transform(value1, value2, chart_name,value3) { 
value3 = typeof value3 !== 'undefined' ? value3 : 'no_header'; 
var chart = nv.models.discreteBarChart() 
    .x(function (d) { 
    return d.label; 
}) 

    .y(function (d) { 
    return d.value; 
}) 

    .staggerLabels(true) 
    .tooltips(false) 
    .showValues(true); 

var a = []; 
var f = [{ 
    values: [] 
}]; 
d3.csv("../../csv/master.csv").get(function (error, rows) { 

if (error){ 
    console.log(error); 
    loadError("Uh Oh. This data set is missing... Try going <a href='/'>back to the start</a>"); 
    return; 
    } 

    for (var i = 0; i < rows.length; i++) { 
     a.push(rows[i]); 
    } 
    console.log(a[0].agency); 
    for (var key = 0; key < a.length; key++) { 
     var b = a[key]; 
     for (var c in b) { 
      if (c != "agency" && c != "division" && c != "pod") { 
       var d = b[c]; 
       a[key][c] = +d; 
      } 
     } 
     console.log(a[0].changes); 
     } 
    try { 
    var e = $.grep(a, function (v) { 
     return v.division == {{division|safe}}; 
     }); 
    var k = $.grep(e, function(v) { 
     return v.agency == {{agency|safe}}; 
     })[0]; 
    console.log(k.division); 
     } 
    catch (TypeError) { loadError("Uh Oh. We could not find this combination\ 
     of Agency & Division. Try going back to the <a href='/pitchview'>selection menu</a>"); 
    return; 
    } 
    if (k.agency){ 
    for (var g in k) { 
     if (g == value1 || g == value2 || g == value3) { 
      var h = { 
       "label": g, 
        "value": k[g] 
      }; 
      f[0].values.push(h); 
     } 
    } 


    d3.select('#' + chart_name + ' svg') 
     .datum(f) 
     .transition().duration(500) 
     .call(chart) 
    nv.utils.windowResize(chart.update); 
    return chart; 
    } else { 
    loadError("Uh Oh. We could not find this combination of Agency &\ 
     Division. Try going back to the <a href='/pitchview'>selection menu</a>");}}); 
} 
+0

당신이'chart.yAxis.ticks (0)'처럼 뭔가를 시도은 y 라벨을 유지할 것인가? –

+0

예, 툴팁 옵션 후 시도했지만 작동하지 않았습니다. 이것은 잘못된 위치입니까? – jvdh

+0

이것은 별도의 코드 라인이 될 것이고, 설정할 옵션이 아닙니다. –

답변

20

(라벨 포함) y 축을 제거 nvd3 이산 바 기능의 변수가있다. 이것을 코드에서 제거하여 제거하십시오 :

.showYAxis(false) 

x 축에 유사한 변수가 있습니다.

+0

이것은 받아 들여진 응답 일 것입니다! 위의 것은 더 많은 해킹입니다! –

3

사용 chart.yAxis.tickValues ​​(0), 그것은 yticks을 끄고

+0

훌륭한 답변 ~ 플러스 1! – Miron

관련 문제