juijs / jui-chart

SVG-based JUI chart that can be used in the browser and Node.js. Support many types of charts. (Dashboard, Map, Topology, Full 3D, Realtime)
https://codepen.io/collection/nLydod/
57 stars 25 forks source link

Bar차트의 합계값을 표시하고 싶습니다. #181

Open dldbwn opened 5 years ago

dldbwn commented 5 years ago

test

  1. 해당 차트의 값의 합계를 각 파트마다 표현을 하고싶습니다. display:all하면 그냥 각 건 수를 표현하더라구요ㅜㅜ
  2. 두번째는 회색은 그대로 표현하고 파랑색만 각각 다른색으로 표현하고싶습니다. 가능할까요?
seogi1004 commented 5 years ago
  1. 툴팁 위젯을 사용하지 마시고, 마크업으로 직접 구현해야할 듯 싶네요. mouseover 이벤트 핸들러에서 obj.data를 콘솔에 찍으시면 모든 데이터가 나옵니다. 직접 합산해서 마크업에 뿌려줘야할 것 같습니다.

http://chartplay.jui.io/?p=brush_event_2

  1. 첫번째 데이터인지를 체크하는 글로벌 변수를 정의하고, 아래와 같이 코드를 작성하면 가능합니다.
var chart = jui.include("chart.builder");
var data = [
    { quarter : "1Q", sales : 50, profit : 35 },
    { quarter : "2Q", sales : -20, profit : -30 },
    { quarter : "3Q", sales : 10, profit : -5 },
    { quarter : "4Q", sales : 30, profit : 25 }
];

var isFirst = false;
window.c = chart("#result", {
    axis : [{
        x : {
            type : "block",
            domain : "quarter",
            line : true
        },
        y : {
            type : "range",
            domain : [ -40, 40 ],
            step : 10,
            line : true
        },
        data : data
    }],
    brush : [{
        type : "column",
        target : [ "sales", "profit" ],
      colors: function(data, index) {
        isFirst = !isFirst;

        if(isFirst) {   
          return "gray";
        } else {
            return index;
        }
      }
    }]
});
dldbwn commented 5 years ago

format으로 해결했습니다. 감사합니다.

seogi1004 commented 5 years ago

@dldbwn 올~ 멋져용~