2

我希望将我的 y 轴的最小值设置为10 less than the lowest value in the Y-axis)。[就像最小值是 83.33(在 Y 轴上),所以我希望将最小值设置为 73.33]

.ValueAxis(axis => axis
.Numeric()
.Labels(labels => labels.Format("{0}"))
.AxisCrossingValue(-10)
.Line(line => line.Visible(false))
.Color("White").Min(MinValueOf Y-axis -10)

或至少 .Min(MinValueOf Y-axis)

我能够解决这个问题......

$("#IndexChart").data("kendoChart").dataSource.read();

                //get reference to the chart widget
                var chart = $("#IndexChart").data("kendoChart");
                chart.bind("dataBound", function (e) {
                    var data = e.sender.dataSource.view(); 
                    //alert(JSON.stringify(data));

                    var allVals = [];//get all Y Axis data...
                    for (var i = 0; i < data.length; i++) {
                        allVals.push(data[i].DuplicatePrice);
                        allVals.push(data[i].OriginalPrice);
                    }

                    var least = Math.min.apply(Math, allVals); //get the least value
                    e.sender.options.valueAxis.min = least - 10; //set the least-10 as min
                });
4

1 回答 1

0

Just to add to Suk's answer, if you're grouping your data, the view method returns an array of groups. For each element in this array, access the items array to get the data for the current group.

    // get filtered (and grouped) data
    var grpData = chart.dataSource.view();
    var allVals = [];

    // loop through all the groups in the view
    for (var grp = 0; grp < grpData.length; grp++) {
        // loop through data in each group
        for (var i = 0; i < grpData[grp].items.length; i++) {
            allVals.push(grpData[grp].items[i].DuplicatePrice);
            allVals.push(grpData[grp].items[i].OriginalPrice);
        }
    }
于 2016-02-19T21:18:05.137 回答