1.1.184 • Published 2 months ago

chartx v1.1.184

Weekly downloads
1,166
License
MIT
Repository
-
Last release
2 months ago

chartx2.0 代码规范

  • 配置使用规范约定

    首先,chartx2.0 和之前的版本使用方式保持一致,需要有 dom 节点, data数据,和配置。

    不同的是2.0中数据支持行列式的数据格式

    var data = [
        [ "xfield", "uv", "pv" ],
        [ 1       ,  2  ,  3   ],
        [ 2       ,  3  ,  4   ]
    ]

    同时也支持json格式列表

    var data = [
       { xfield: 1, uv:2, pv:3  },
       { xfield: 1, uv:2, pv:3  },
       { xfield: 1, uv:2, pv:3  }
    ]

    chartx会主动识别并且处理,只要符合其中一种数据格式,你就只管塞就好了。

    然后,chartx2.0中 所有的图标类型都会提供一份根据数据来得默认配置,也就是说,你可以只要有数据,不用些任何配置,就可以创建一个图表:

    Chartx.Line( "dom" , data, {} ) 
    //最后面的那个配置可以不要,Chartx.Line( "dom" , data )
    //那么比如在直角坐标系中,我们会默认拿第一个字段xfield作为xAxis.field, 其他字段都作为yAxis.field

chartx2.0 相比1.xxx 更加纯粹的采用了组件式配置的原则,比如一个直角坐标系的折线图line,它的配置会是这样

//其中除开coordinate 和 graphs 默认会有以外,其他的所有 组件 都是组装式的,在options 里面组装了这个组件,才会有对应的功能,2.0里面包括tips也不再默认放出( 这么多年的经验得出,默认的tips基本没有可看性,项目里面基本会对tips.content重构 )
var options = {
    coordinate : {
        xAxis : {},
        yAxis : {}
    },
    graphs : {

    },
    legend : {

    },
    markLine : {

    },
    markPoint : {

    },
    dataZoom: {

    },
    tips : {

    }
}
  • 图表类视图规划

    2.0中,把图表区 按照坐标系类别分类,而不在是单独个图表类型,各自写各自的逻辑代码

    • Chart
      • Descartes(笛卡尔坐标系)
        • bar
        • line
        • bar_line
        • bar_tgi
        • scat
      • Polar(极坐标系)
        • Pie
        • Dingle(丁格尔玫瑰图)
        • Planet (星云图)
      • Other
  • 接口约定规范

    ** chart 图表基类

    1,这次添加了组件管理机制 components

    2,然后,对于reset 和 resetData两个接口,这次做了绝对清晰的划分,也就是reset 实质上和重新绘制是一回事,而resetData却仅仅是数据的变化,然后调用各个组价的resetData 来实现整体数据的更新( 之前版本里做的太复杂,reset会去计算用户reset的意图,比如reset里少了个yAxis的字段,那么就会自动remove掉一条线,这是个大坑,而且性价比非常低,但是代码量和可维护性非常低 )

    ** descartes 笛卡尔系统类( bar,line,scat 等都继承自该类 )

简单代码约定规范

_coordinate 为实例 coordinate 为配置

交互事件的规范 1.xx 版本中,所有的事件都是在 chart.on("nodeclick") 等这样的层面实现的

2.0中,所有的事件都写入到配置中去

比如在scat中得节点点击事件

 graphs : [
       {
           type : "scat",
           field : "money",
           groupField : "sex",
           node : {
               r : "house", 

               //事件直接注册到对于的配置中来,这样,减少了命名的麻烦,统一的命名,而且直观, 
               //一眼就知道在那些元素上面注册了事件
               onclick : function( nodeData, Graphs ){
                   debugger
               }
           }
       }
   ]

file:../canvax

直角坐标系的两类轴(xAxis,yAxis),和极坐标系的两类轴(aAxis,rAxis ), 都至少有field和ruler ruler用来表示刻度ui,axis上面别的所有的属性都是逻辑属性,ruler用来控制是否有ui。

graphs 约定 所有得graphs中把所有的ui设置都归为了4个属性(这么多年的经验来看, 基本能满足目前为止的所有需求) node --》 (对应一个数据节点,而不是ui元素) line --》(多个数据节点的链接,在雷达图和line折线图中表现为用折线绘制连接) area --》(同样地,表示多个数据节点的链接,然后有一个闭环,出现了一个面) text --》 文本

所有组件对外影响的时候都会抛出一个 trigger对象 trigger对象包括comp(触发的组件)和params两个属性

nodeData, nodeElement , data和图形之间互相引用的属性约定

颜色取值规则,只有undefined才会认为需要还原皮肤色 “” 或者 null 都会认为是用户主动想要设置的,就为是用户不想他显示

启动文档服务

docsify serve docs

1.1.184

2 months ago

1.1.183

2 months ago

1.1.182

2 months ago

1.1.181

4 months ago

1.1.180

5 months ago

1.1.179

5 months ago

1.1.177

5 months ago

1.1.174

7 months ago

1.1.173

7 months ago

1.1.172

7 months ago

1.1.171

9 months ago

1.1.170

9 months ago

1.1.169

9 months ago

1.1.168

10 months ago

1.1.167

10 months ago

1.1.166

10 months ago

1.1.165

10 months ago

1.1.164

10 months ago

1.1.163

11 months ago

1.1.162

11 months ago

1.1.161

11 months ago

1.1.160

11 months ago

1.1.159

12 months ago

1.1.157

1 year ago

1.1.156

1 year ago

1.1.155

1 year ago

1.1.154

2 years ago

1.1.153

2 years ago

1.1.152

2 years ago

1.1.144

2 years ago

1.1.143

2 years ago

1.1.149

2 years ago

1.1.148

2 years ago

1.1.147

2 years ago

1.1.146

2 years ago

1.1.145

2 years ago

1.1.151

2 years ago

1.1.150

2 years ago

1.1.142

2 years ago

1.1.140

2 years ago

1.1.139

2 years ago

1.1.138

2 years ago

1.1.137

2 years ago

1.1.133

2 years ago

1.1.132

2 years ago

1.1.131

2 years ago

1.1.130

2 years ago

1.1.136

2 years ago

1.1.135

2 years ago

1.1.134

2 years ago

1.1.129

2 years ago

1.1.128

2 years ago

1.1.127

2 years ago

1.1.126

2 years ago

1.1.125

2 years ago

1.1.124

2 years ago

1.1.123

2 years ago

1.1.122

2 years ago

1.1.121

2 years ago

1.1.100

2 years ago

1.1.108

2 years ago

1.1.107

2 years ago

1.1.105

2 years ago

1.1.104

2 years ago

1.1.103

2 years ago

1.1.102

2 years ago

1.1.101

2 years ago

1.1.92

2 years ago

1.1.91

2 years ago

1.1.120

2 years ago

1.1.96

2 years ago

1.1.95

2 years ago

1.1.94

2 years ago

1.1.93

2 years ago

1.1.99

2 years ago

1.1.98

2 years ago

1.1.97

2 years ago

1.1.109

2 years ago

1.1.111

2 years ago

1.1.110

2 years ago

1.1.119

2 years ago

1.1.118

2 years ago

1.1.117

2 years ago

1.1.116

2 years ago

1.1.115

2 years ago

1.1.114

2 years ago

1.1.113

2 years ago

1.1.112

2 years ago

1.1.85

3 years ago

1.1.83

3 years ago

1.1.82

3 years ago

1.1.89

2 years ago

1.1.88

3 years ago

1.1.87

3 years ago

1.1.86

3 years ago

1.1.78

3 years ago

1.1.79

3 years ago

1.1.81

3 years ago

1.1.80

3 years ago

1.1.70

3 years ago

1.1.73

3 years ago

1.1.72

3 years ago

1.1.71

3 years ago

1.1.77

3 years ago

1.1.76

3 years ago

1.1.75

3 years ago

1.1.69

3 years ago

1.1.68

3 years ago

1.1.56

3 years ago

1.1.55

3 years ago

1.1.59

3 years ago

1.1.58

3 years ago

1.1.57

3 years ago

1.1.63

3 years ago

1.1.62

3 years ago

1.1.61

3 years ago

1.1.60

3 years ago

1.1.67

3 years ago

1.1.66

3 years ago

1.1.65

3 years ago

1.1.64

3 years ago

1.1.54

3 years ago

1.1.52

3 years ago

1.1.51

3 years ago

1.1.53

3 years ago

1.1.50

3 years ago

1.1.49

4 years ago

1.1.48

4 years ago

1.1.47

4 years ago

1.1.46

4 years ago

1.1.45

4 years ago

1.1.44

4 years ago

1.1.43

4 years ago

1.1.42

4 years ago

1.1.41

4 years ago

1.1.40

4 years ago

1.1.39

4 years ago

1.1.38

4 years ago

1.1.37

4 years ago

1.1.34

4 years ago

1.1.36

4 years ago

1.1.35

4 years ago

1.1.33

4 years ago

1.1.32

4 years ago

1.1.31

4 years ago

1.1.30

4 years ago

1.1.29

4 years ago

1.1.28

4 years ago

1.1.27

4 years ago

1.1.26

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.23

4 years ago

1.1.22

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.169

5 years ago

1.0.168

5 years ago

1.0.167

5 years ago

1.0.166

5 years ago

1.0.164

5 years ago

1.0.163

5 years ago

1.0.161

5 years ago

1.0.160

5 years ago

1.0.159

5 years ago

1.0.158

5 years ago

1.0.157

5 years ago

1.0.156

5 years ago

1.0.155

5 years ago

1.0.154

5 years ago

1.0.153

5 years ago

1.0.152

5 years ago

1.0.151

5 years ago

1.0.150

5 years ago

1.0.149

5 years ago

1.0.148

6 years ago

1.0.147

6 years ago

1.0.146

6 years ago

1.0.145

6 years ago

1.0.144

6 years ago

1.0.143

6 years ago

1.0.142

6 years ago

1.0.141

6 years ago

1.0.140

6 years ago

1.0.139

6 years ago

1.0.138

6 years ago

1.0.137

6 years ago

1.0.136

6 years ago

1.0.135

6 years ago

1.0.134

6 years ago

1.0.133

6 years ago

1.0.132

6 years ago

1.0.131

6 years ago

1.0.130

6 years ago

1.0.129

6 years ago

1.0.128

6 years ago

1.0.127

6 years ago

1.0.126

6 years ago

1.0.125

6 years ago

1.0.124

6 years ago

1.0.123

6 years ago

1.0.122

6 years ago

1.0.121

6 years ago

1.0.120

6 years ago

1.0.119

6 years ago

1.0.118

6 years ago

1.0.117

6 years ago

1.0.116

6 years ago

1.0.115

6 years ago

1.0.113

6 years ago

1.0.112

6 years ago

1.0.111

6 years ago

1.0.110

6 years ago

1.0.109

6 years ago

1.0.108

6 years ago

1.0.107

6 years ago

1.0.106

6 years ago

1.0.105

6 years ago

1.0.104

6 years ago

1.0.103

6 years ago

1.0.102

6 years ago

1.0.101

6 years ago

1.0.100

6 years ago

1.0.99

6 years ago

1.0.98

6 years ago

1.0.97

6 years ago

1.0.96

6 years ago

1.0.95

6 years ago

1.0.93

6 years ago

1.0.92

6 years ago

1.0.91

6 years ago

1.0.90

6 years ago

1.0.89

6 years ago

1.0.88

6 years ago

1.0.87

6 years ago

1.0.86

6 years ago

1.0.85

6 years ago

1.0.84

6 years ago

1.0.83

6 years ago

1.0.82

6 years ago

1.0.81

6 years ago

1.0.80

6 years ago

1.0.79

6 years ago

1.0.78

6 years ago

1.0.77

6 years ago

1.0.76

6 years ago

1.0.74

6 years ago

1.0.73

6 years ago

1.0.72

6 years ago

1.0.71

6 years ago

1.0.70

6 years ago

1.0.69

6 years ago

1.0.68

6 years ago

1.0.67

6 years ago

1.0.66

6 years ago

1.0.65

6 years ago

1.0.64

6 years ago

1.0.63

6 years ago

1.0.62

6 years ago

1.0.61

6 years ago

1.0.60

6 years ago

1.0.59

6 years ago

1.0.58

6 years ago

1.0.57

6 years ago

1.0.56

6 years ago

1.0.55

6 years ago

1.0.53

6 years ago

1.0.52

6 years ago

1.0.51

6 years ago

1.0.50

6 years ago

1.0.49

6 years ago

1.0.48

6 years ago

1.0.47

6 years ago

1.0.46

6 years ago

1.0.45

6 years ago

1.0.44

6 years ago

1.0.43

6 years ago

1.0.42

6 years ago

1.0.41

6 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

7 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago