我的学习笔记11.29

这篇博客详细分析了Echarts中的不同坐标系组件,包括Grid直角坐标系、Polar极坐标系、Radar雷达坐标系和Parallel平行坐标系。文章探讨了各个组件的实现原理,如Grid的渲染、Polar的创建、Radar的数据转换以及Parallel的初始化和轴处理。此外,还介绍了地理坐标系的几个关键部分,如geo.js、GeoMode和MapDraw地图绘制。
摘要由CSDN通过智能技术生成

2021SC@SDUSC

echarts源码分析之坐标系

坐标系

Grid 直角坐标系

Grid为echarts中的直角坐标系组件。

gridSimple

gridSimple通过extendComponentView扩展自Component View,重写了render方法,主要代码如下:

render: function (gridModel, ecModel) {
    this.group.removeAll();
    if (gridModel.get('show')) {
        this.group.add(new graphic.Rect({
            shape: gridModel.coordinateSystem.getRect(),
            style: zrUtil.defaults({
                fill: gridModel.get('backgroundColor')
            }, gridModel.getItemStyle()),
            silent: true,
            z2: -1
        }));
    }
}

Grid.js

coord/cartesian/Grid.js,实现直角坐标系的渲染,主要代码如下:

function Grid(gridModel, ecModel, api) {
    ...
    this._initCartesian(gridModel, ecModel, api);
    ...
}
gridProto._initCartesian = function (gridModel, ecModel, api) {
    var axisPositionUsed = {
        left: false,
        right: false,
        top: false,
        bottom: false
    };
    var axesMap = {
        x: {},
        y: {}
    };
    var axesCount = {
        x: 0,
        y: 0
    };

    /// Create axis
    // 创建x及y坐标轴
    ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
    ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
    ...
    /// Create cartesian2d
    // 创建
    each(axesMap.x, function (xAxis, xAxisIndex) {
        each(axesMap.y, function (yAxis, yAxisIndex) {
            var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
            var cartesian = new Cartesian2D(key);

            cartesian.grid = this;
            cartesian.model = gridModel;

            this._coordsMap[key] = cartesian;
            this._coordsList.push(cartesian);

    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值