Lucas Lopes
Lucas Lopes

Reputation: 86

set symbol height in highchart

I have a pie chart and I need to change the size of the symbols in the legend, but there's only setSymbolWidth. How do I change the height of the symbol? I'm using Moxie Group's GWT highchart, but if there's a way in solving this with the javascript highcharts I'm probably able to do it in the GWT version.

I tried this solution http://jsfiddle.net/MEr2n/ but the series property is returning null (don't know why) even after I add a series to the chart. I'm also not sure this would work because it seems this solution gets the SVG element of the legend from the serie and set its property directly, in my case there is one serie and a symbol for each point in the serie.

Upvotes: 0

Views: 1008

Answers (1)

Lucas Lopes
Lucas Lopes

Reputation: 86

I solved it. Unfortunately I needed to create a very ugly workaround for this. At least it worked. My solution was:

NodeList<Element> gElements = chart.getElement().getElementsByTagName('g');

for (int i = 0; i < gElements.getLength(); i++) {
    Element gel = gElements.getItem(i);

    if (gel.getAttribute("class").equals("highcharts-legend")) {
        NodeList<Element> elements = gel.getElementsByTagName("rect");

        for (int j = 0; j < elements.getLength(); j++) {
            elements.getItem(j).setAttribute("height", "8");
        }
        break;
    }
}

I guess I could have used gwt-jquery to get the g element with the highcharts-legend class, but I don't want to add another API just for this.

Upvotes: 0

Related Questions