Jump to content

How to customize axis label on unichart uni bar


CITASys Automation

Recommended Posts

  • 1 year later...

Solution:

function chart.beforeInit(sender, config) 
{
    //axisY
    config.axes[0].renderer = function(s, v, a) {
        a.attr.canvasAttributes.strokeStyle = 'green';
        a.attr.canvasAttributes.lineWidth = 1.5;
        return v
        // or using number formatting
        //return Ext.util.Format.number(v, "#.00") 
    };
    
    //axisX
    config.axes[1].renderer = function(s, v, a) {
        a.attr.canvasAttributes.strokeStyle = 'blue';
        a.attr.canvasAttributes.lineWidth = 1.5;
        return v
        // or using number formatting
        //return Ext.util.Format.number(v, "#.00") 
    }; 
}

 

Turns out, I already gave a similar solution:

 

Link to comment
Share on other sites

Thank for your response and sorry for my late response(have been out of workplace for the long weekend).

Your solution works, but it destroys other property of UniChart which is Axes->CustomLabels (Example on screenshots below).

How can i set custom labels on the Y-axis and at the same time having your solution for coloring axis?

image.png.337492af6084fc3bc6cd955a1e0360ad.png

image.png.a2a5a13008ccaa9ee8721d48469b052b.png 

Link to comment
Share on other sites

function chart.beforeInit(sender, config) 
{
    //axisY
    config.axes[0].renderer = function(s, v, a, f) {
        a.attr.canvasAttributes.strokeStyle = 'green';
        a.attr.canvasAttributes.lineWidth = 1.5;

        if (Ext.isArray(s.cLables)) {
            var _a = s.uLastIx;
            if (f === null) {
                _a = 0
            }
            s.uLastIx = _a + 1;
            if (_a < s.cLables.length) {
                return s.cLables[_a]
            }
        }
        if (s.hideLabel == true) {
            return ""
        }

        return v
        // or using number formatting
        //return Ext.util.Format.number(v, "#.00") 
    };

    //axisX
    config.axes[1].renderer = function(s, v, a, f) {
        a.attr.canvasAttributes.strokeStyle = 'blue';
        a.attr.canvasAttributes.lineWidth = 1.5;

        if (Ext.isArray(s.cLables)) {
            var _a = s.uLastIx;
            if (f === null) {
                _a = 0
            }
            s.uLastIx = _a + 1;
            if (_a < s.cLables.length) {
                return s.cLables[_a]
            }
        }
        if (s.hideLabel == true) {
            return ""
        }

        return v
        // or using number formatting
        //return Ext.util.Format.number(v, "#.00") 
    };
}

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...