Kendo stickers at the top?

How to change the location of shortcuts based on a kendo chart? Consider the following script: http://jsfiddle.net/ZPUr4/149/

In a chart, for positive values, the column values ​​are at the top and for negative values, the column values ​​are at the bottom.

How to place label label values ​​at the top of columns for positive and negative values?

How to get all label values ​​in the same horizontal line, even if the bar values ​​change?

Let me know if my question is not clear.

The following is the HTML code:

    <div id="example" class="k-content">
    <div id="chart"></div>
</div>

JS Code:

function createChart() {
        $("#chart").kendoChart({
            title: {
                text: "Site Visitors"
            },
            legend: {
                position: "bottom"
            },
            seriesDefaults: {
                type: "column",
                labels: {
                    visible: true,
                    background: "transparent",

                }
            },
            series: [{
                name: "Total Visits",
                data: series1,
                gap: 1.0,
                spacing: 0
            }, {
                name: "Unique visitors",
                data: series2,
                gap: 1.0
            }],
            valueAxis: {
                min: -200000,
                max: 200000,
                axisCrossingValue: 50000,  
                line: {
                    visible: false
                },
                title: {
                    text: "Availability"
                },

                color: 'blue'
            },
            categoryAxis: {
               color: "blue",
                width: 25,
                majorGridLines: {
                    visible: true,
                    position: "bottom"
                },
                line: {
                    width: 3,
                }
            },
            tooltip: {
                visible: true,
                format: "{0}"
            }
        });
    }

var series1=[56000, 63000, 74000, 91000, 117000, 158000];
var series2= [-52000, 34000, 23000, -98000, 67000, 83000];

    $(document).ready(function () {
        createChart();

        $("#example").bind("kendo:skinChange", createChart);

        var chart = $("#chart").data("kendoChart"),
            firstSeries = chart.options.series;
    });

Thank.

+4
source share
3 answers

, , :

labels: {
    visible: true,
    position: "top"
}

, . , :

labels: {
    visible: true,
    position: "top",
    padding: {
        top: -20
    }
}

padding.top 20pix, .

JSFiddle : http://jsfiddle.net/OnaBai/ZPUr4/178/

+6

, , , - .

, .

function chartBound(e) {
    var chartData = e.sender;
    var oldPrivateRedraw = chartData._redraw;
    if (oldPrivateRedraw.toString().indexOf('Extend') == -1) { //not already extended
        //Extends kendos function so we can do custom styling to svg components etc
        chartData._redraw = function () {
            oldPrivateRedraw.apply(chartData);
            PostGraphDrawEvents();
        };
    }
}
function PostGraphDrawEvents() {
    // Move the labels to the top of the graph
    $.each($('#@chartId svg > g > text[style*="11px"]'), function (index, node) {
        var clonedNode = node.cloneNode(true);
        $(clonedNode).attr('y', 10);
        $(node).before(clonedNode);
    });
}
0

Heading ------- .    , .

Markdown and HTML are turned off in code blocks:
<i>This is not italic</i>, and [this is not a link](http://example.com)

, , :

$ - window.jQuery. , :

  • .
  • , :

    Skip a line and indent eight spaces.
    That four spaces for the list
    and four to trigger the code block.
    
0
source

Source: https://habr.com/ru/post/1542933/


All Articles