这些是我的JavaScript应用程序中的一些类:
myApp.mode.model Handles the state
myApp.mode.controller Instantiates and updates components based on the model
myApp.data.dataManager Does operations on the dataSource
myApp.data.dataSource A big singleton with structured data
myApp.chart.grid A grid component
myApp.chart.scatter A scatter gram renderer
myApp.chart.tooltip A tooltip renderer
这些组件之间的交互如下所示:(对不起的错觉技能。;))
我正在寻找一种干净的方法,将必要的参数(依赖管理)传递给Visualization Controller 的子组件:
假设用户更改了可视化显示中的指示器。该模型要求数据管理器加载必要的数据。
加载数据后,可视化 Controller 将了解模型更改,并应更新其各自的组件:网格,散布图,工具提示等。
网格需要了解xMin,xMax,宽度,高度等信息。
“散点图渲染器”还需要xMin,xMax,宽度,高度。 此外,它还需要访问大数据单例,并且需要找出要绘制的数据部分。
三个问题:
谢谢 :)
最佳答案
您可能想看看AngularJS,因为它具有DI功能(以支持更轻松的测试)。