是否可以在 Kendo 图表上设置最小和最大缩放比例?由于有很多项目,我的图表在缩小时使类别轴标签难以辨认

Is there a min and max zoom that can be set on a Kendo chart? My chart upon zooming out makes category axis label illegible due to many items

我有一个 kendo Angular 图表组件,我需要在其上设置最小缩放比例,以便在一个点之后,缩小不是一个选项,否则类别轴标签变得难以辨认读。同样,我也想设置最大缩放。您可以在 gif 中看到图表问题。

使用驱动器是因为文件大小 > 2 Mb,并且堆栈溢出不允许这样做。

https://drive.google.com/file/d/1aOXLmnCgOIUb7fVT5pkQ6lbWb8IvAxhK/view

您可以使用 zoom 事件。您无法检查缩放级别是多少,但可以检查查看范围是多少,如果范围超出您的偏好,则阻止缩放操作。

假设类别是数字,您最多希望看到 20 个类别。

这里是完成你想做的事情的要点:

  1. 为您的分类轴命名:

    public categoryAxis: any = {
        min: 10,
        max: 20,
        name: "test"
    };
    
  2. 将事件处理程序添加到 kendo-chart 组件:

    (zoom)=zoomHandler($event)
    
  3. 给组件添加事件处理函数:

    public zoomHandler(e) {
        console.log("zoom", e);
    
        // Prevent the zoom action if the axis range is greater than 20 (in this example, the categories are numbers)
        if (e.axisRanges.test.max - e.axisRanges.test.min > 20) {
            e.preventDefault();
        }
    }
    

你可以看一个例子here