antvis / data-set Goto Github PK
View Code? Open in Web Editor NEWstate driven all in one data process for data visualization.
License: MIT License
state driven all in one data process for data visualization.
License: MIT License
RT,源码中取data.features,features字段只会在FeatureCollection中出现。标准的GeoJSON类型还有很多,Feature, Point, Polygon等等,目前拿到数据后需要自己再包一层。
data-set/src/connector/geojson.js
Line 15 in 55526ac
像下面这样初始化的时候已经设置了 connector, transform:
dv.source(data, {
type: 'topojson',
});
dv.transform({
type: 'filter',
callback(row) {
return row.Run !== "1";
}
});
如果我此时有新的 data, 可以重新使用 source
方法设置数据, 这时候会重新用原来的 transform 的来处理一遍新数据。
但是依旧需要在 souce
方法中提供 connector 配置, 这个 connector 有必要在重新传进去吗? 按我的理解是应该复用, 虽然传进去也没什么问题。
或者有什么其他用来设置新的数据的方法?
data-set version: 0.10.1
Webpack build failed with webpackConfig.resolve.mainFields = ['module', 'main'], for less bundle size via tree shaking.
But the value of field module
is 'src/index.js' which would cause minifying code unsuccessfully, when using uglifyjs-webpack-plugin
.
What expected is:
Compile 'src/index.js' to 'es/index.js' like 'lib/index.js', but without transforming import/export.
and package.json
{
"module": "es/index.js",
}
or hot fix with
{
"module": "lib/index.js",
}
我只想用一些简单的transform功能,但是要引入整个data-set包太不合理,而且data-set包不是一般的大,能够将各个功能点进行拆分,让使用者可以按需加载?
const dv = new DataSet.view();
dv.source(src, options);
dv.transform(options).transform(options);
dv.ready((data, dv) => {
});
readme上的api文档链接失效了,跳转404
版本 0.9.4
从最终打包版本看,内部约有12处依赖了 lodash,导致引入 data-set 后会覆盖 window._ 变量
// 直方图
chart.interval().position(Stat.summary.count(Stat.bin.rect('depth')));
// 六边形封箱
chart.polygon().position(Stat.summary.bin('x*y')).color(Stat.summary.count());
chart.polygon().position(Stat.summary.bin('x*y')).color(Stat.summary.max('z'));
d3-hexjson
依赖项中含有es6语法 const
https://github.com/olihawkins/d3-hexjson/blob/master/build/d3-hexjson.js#L191
例子:
let ds = [
{name: "有餐厅", value: "91"},
{name: "有吃饭的地", value: "58"},
{name: "有停车场", value: "50"},
{name: "西单边", value: "37"},
{name: "位置很好", value: "23"},
{name: "强烈推荐", value: "21"}
];
let dv = new DataSet.View().source(ds);
dv.transform({
type: 'tag-cloud',
fields: 100,
size: [0, -100],
font: 'serif',
padding: 0,
spiral: 'archimedean',
fontSize(d) { return d.value / 5 },
timeInterval: Infinity,
});
程序将在data-set/src/util/tag-cloud.js l311-l320 陷入死循环
npm install @antv/data-set
npm ERR! Unexpected end of JSON input while parsing near '...t3pObWDojJKhiYBF7X1m8'
请问怎么解决?
`
const dv = new DataSet().createView().source([
{
item: '2019',
columnValue: 1.01,
type: 'a'
},
{
item: '2019',
columnValue: 2.01,
type: 'a'
},
{
item: '2020',
columnValue: 1.01,
type: 'a'
},
{
item: '2020',
columnValue: 2.22,
type: 'a'
},
])
dv.transform({
type: 'aggregate', // 别名summary
fields: ['columnValue'], // 统计字段集
operations: ['sum'], // 统计操作集
as: ['value'], // 存储字段集
groupBy: ['item', 'type'], // 分组字段集
})
console.log('dv', dv.rows)
`
sum 使用的第三方库 simple-statistics 里面并没有处理浮点计算精度丢失问题
希望能修复这个问题,感谢
按照官方的指引安装,并引用报错
npm install @antv/data-set;
import DataSet from '@antv/data-set';
错误信息如下:
[ts]
Could not find a declaration file for module '@antv/data-set'. '/home/likewise-open/SENSETIME/liulin/sense-radar/node_modules/@antv/data-set/build/data-set.js' implicitly has an 'any' type.
Try `npm install @types/antv__data-set` if it exists or add a new declaration (.d.ts) file containing `declare module 'antv__data-set';`
Environment | Info |
---|---|
@antv/data-set | 0.11.4 |
System | mac |
Browser | 谷歌84 |
Sturges formula:
export function sturges(values: Array<number>): number {
return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
}
支付宝小程序要写一个词云,头秃
As the title says, expect typings benefits in developing.
In my opinion , data-set is used as a kind of transformation. Or, exactly, transformation is a very important part of data-set.
However, I don't think the transformation should be done in frontend of browser.
Would you please give a way to do it in Node.js , which plays as a middle proxy server in my project.
Should I operate by just taking node as browser to get it done?
Like :
data
into dataview
dataview.rows
It's confusing reading the docs while it's not specific to node.
Looking forward to your answer.
data-set/src/connector/geojson.js
Lines 13 to 35 in ead42aa
在执行transform时,dataview会把源数组clone到transform数组。但是用到的克隆算法无法正确克隆Date类型。克隆出来的数据是一个空对象。
I am using viserjs to show a single chart. I use date-set to pivot the data to an Pie Chart, like the code below.
import DataSet from "@antv/data-set";
const dv = new DataSet.View().source(data);
dv.transform({
type: "percent",
field: this.measureName,
dimension: this.dimensionName,
as: "percent"
});
Is there some way to import just the transform part of the @antv/data-set lib (ex.: import {transform} from "@antv/data-set"
)?
After build, the size of @antv/data-set is big, but my code does not need everthing!
npm run dev
for developing, instead of npm run dev
plus npm run test-live
const dv = ds
.createView()
.source(rawData)
.transform({
type: 'map',
callback(row) {
sumRealityDaily += row['实际每日达成'];
sumPredictionDaily += row['预计每日达成'];
if (Number(row['日期']) < 4.6) {
row['汇总实际每日达成'] = sumRealityDaily;
} else {
row['汇总预计每日达成'] = sumPredictionDaily;
}
return row;
},
})
.transform({
type: 'fold',
fields: ['实际每日达成', '预计每日达成'], // 展开字段集
key: 'type', // key字段
value: 'value', // value字段
});
最后一个transform转换完丢失 '汇总预计每日达成' 字段
hope support types for typescript
按照项目package.json中的配置,lib目录下应该是存放babel编译之后的代码,但是发现其中依然存在ES6语法:
view.js
class View extends EventEmitter {
...
}
data-set.js
class DataSet extends EventEmitter {
...
}
一般我们在进行项目webpack打包的时候习惯将node_modules下的文件exclude,因此希望能够提供的lib目录下不要出现ES6语法。
kde 中有一行:
const seriesValues = getSeriesValues(extent, options.step ? options.step : bw);
getSeriesValues 源码如下:
module.exports = (extent, bandwidth = 1) => {
const [ min, max ] = extent;
const values = [];
let tmp = min;
while (tmp < max) {
values.push(tmp);
tmp += bandwidth;
}
values.push(max);
return values;
};
当 bandwidth 是0 ,max 又很大的时候,会出现无限循环
复现步骤:
已经安装好npm包,使用时也引入了组价,离线状态下,无法显示图表组件。
npm install @antv/data-set;
import DataSet from '@antv/data-set';
这是因为我使用了typescript的原因吗?在线情况下注释掉
<!-- 引入在线资源 -->
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.data-set-0.9.6/dist/data-set.min.js"></script>
也无法使用图表组件,按理说我已经安装了离线包应该不需要再引入在线资源了。
错误日志:
[ts]
无法找到模块“@antv/data-set”的声明文件。“c:/Users/william/Documents/sky-data-backend/node_modules/@antv/data-set/build/data-set.js”隐式拥有 "any" 类型。
Try `npm install @types/antv__data-set` if it exists or add a new declaration (.d.ts) file containing `declare module '@antv/data-set';`
module "c:/Users/william/Documents/sky-data-backend/node_modules/@antv/data-set/build/data-set"
离线状态下一直显示loading。
const dv = new DataView();
dv.source(data).transform({
type: 'percent',
field: 'y',
dimension: 'x',
as: 'percent',
});
If y is all 0, percent is NaN, expect 0.
ERROR in scripts/f00180b2630cc99c1972.js from UglifyJs
Unexpected token: operator (>) [./node_modules/@antv/data-set/src/util/get-geo-projection.js:7,0][scripts/f00180b2630cc99c1972.js:1,120]
代码,项目地址:
https://github.com/dreambo8563/ts_react_mobx
直接clone项目 安装后 npm run build即可重现
我在dataset里面有两个data view: timev 和 timev2.
//该代码只会触发timev2的刷新
this.timeSource.addViewData('timev',data)
this.timeSource.addViewData('timev2',data1)
// 拉开两次设置数据的时间,则两个view都能够刷新
setTimeout(()=>{
this.timeSource.addViewData('timev',data)
},100)
setTimeout(()=>{
this.timeSource.addViewData('timev2',data1)
},500)
😄
关于 data-view 的 transform 我只看到了如何添加, 以及获取, 但并没有看到如何移除的办法 。
看了源码,发现只能直接操作 transform 的数组, 但是这样带来的问题是, 数据并没有重新转换
源码中有重新执行的方法 _reExecuteTransforms
, 但是这个应该是私有方法吧
所以如何保证移除 tranform 后, 获取的处理数据为剩余的 transform 处理后的数据呢? 或者说你们并不推荐这种用法?
RT:transform diagram.sankey 不支持排序
*Link:
dv.transform({
type: 'pick',
fields: [ 'xxx', 'yyy' ] // 决定保留哪些字段,如果不传,则返回所有字段
});
能不能再加个反向的逻辑, 即, 决定不保留哪些字段? 看了下源码, 没太看懂怎么加....
如果如下简单凑合也是能用的, 但这种, 不能 dv.transform...transform...transform...而且可能还有其他问题
fields: Object.keys(dv.rows[0]).filter(f=> !['zzz', 'aaa'].includes(f))
Yarn Version: 1.0.0
我在create-react-app脚手架下想使用data-set,但是使用yarn add @antv/data-set命令安装时报错:
如果去掉@AntV的话就会去安装重名包[email protected]
我查询了yarn中文官网提供的add参数:
发现可能安装的好像只有yarn add <git remote url>方式
但是我通过这种方式总是会卡死在Resolving Packages
我想请问一下是不是用yarn安装的话只能通过git remote url的方式呢?
在ie9为什么他又报 “引发了异常但未捕获data-set.min.js (1,30929)”
this.dataSet);else if(Array.isArray(n))this.origin=n;else{if(!f(n)||!n.type) 这是data-set.min.js中的那行代码
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.