the tips of the bar chart in wijmo 3

1. Hide the label on each bar
 var _chartLabels = $("#wijbarchartPro").wijbarchart().data().fields.chartElements.chartLabels; $.each(_chartLabels, function (index, elem) {
   if((index%2)==1){elem.attr('text', '');}
 });


2. rotation label on bar


chartLabelStyle: {rotation: 90},

3. 
You can get the path element of the axis using the following properties :

xaxis  = $(“#wijbarchart”).wijbarchart().data().wijbarchart.axisEles[0].attrs.path[0];
yaxis = $(“#wijbarchart”).wijbarchart().data().wijbarchart.axisEles[0].attrs.path[1];

4.
The chartLabels[index].attrs.x and chartLabels[index].attrs.y return the positiong of the label.
For instance, to get the position of first label upi may use the following js :
var x = $(“#wijbarchart”).wijbarchart().data().fields.chartElements.chartLabels[0].attrs.x;
var y = $(“#wijbarchart”).wijbarchart().data().fields.chartElements.chartLabels[0].attrs.y;

5.Change Bar Color


mouseOut: function (e, data) {
         //data.bar.attr({ fill:'#799foa',stroke:'#9062bd'});

        for(var i=0;i < data.bar.length ; i++){
            bars[i].attr({ fill:'#799foa',stroke:'#9062bd'});
        }

 },    



6.Change Bar Color Script
Copy Code from http://wijmo.com/docs/wijmo/ChangeBarColorByValue.html

<script type="text/javascript">
    var fill = "";
    $(document).ready(function () {
        $("#chart").wijbarchart({
            header: {text: "Big Ten Championships"},
            horizontal: false,
            seriesList: [{
                label: "Big Ten Championships",
                legendEntry: false,
                data: {
                    x: ['Illinois', 'Indiana', 'Iowa', 'Michigan', 'Michigan State',
                        'Minnesota', 'Nebraska', 'Northwestern', 'Ohio State',
                        'Penn State', 'Purdue', 'Wisconsin'],
                    y: [230, 167, 105, 351, 84, 178, 3, 69, 185, 57, 69, 183]
                }
            }],
            mouseOut: function (e, data) {
                var y = data.y,
                bar = data.bar;
                if (y < 100) {
                    bar.attr({ fill: "red", stroke: "none" });
                }
                if (y > 100 && y < 200) {
                    bar.attr({ fill: "yellow", stroke: "none" });
                }
                if (y > 200) {
                    bar.attr({ fill: "green", stroke: "none" });
                }
            }
        });
    var bars = $("#chart").data("fields").chartElements.bars;
    $.each(bars, function (i, bar) {
        var node = bar.node,
        data = $(node).data("wijchartDataObj"),
        y = data.y;
        if (y < 100) {
            bar.attr({ fill: "red", stroke: "none" });
        }
        if (y > 100 && y < 200) {
            bar.attr({ fill: "yellow", stroke: "none" });
        }
        if (y > 200) {
            bar.attr({ fill: "green", stroke: "none" });
        }
    })
});
</script>

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE