[英]editablegrid set columns for rendering a bar chart graph
I'm using editableGrid for my project and I want to create a graph, with values from only 1 column. 我正在为我的项目使用editableGrid ,我想创建一个图形,其值仅来自1列。
When using renderBarChart()
function , the table renders a graph, but with all numeric columns (set in metadata as integer or double) as data. 使用renderBarChart()
函数时 ,表将呈现图形,但所有数字列(在元数据中设置为整数或双renderBarChart()
)均作为数据。 So I have graph with data which are not related at all. 所以我有完全无关的数据图。 Is there a way, how to force the graph to load data from 1 column (eg. only price)? 有没有一种方法,如何强制图形从1列加载数据(例如,仅价格)?
Ok, I figured it out. 好的,我知道了。 Only thing you have to do is set columns in metadata part with attribute bar: false
in order to remove those columns from rendering in graphs. 只需要做的就是在元数据部分中使用属性bar: false
设置列bar: false
,以便从图中的呈现中删除这些列。
editableGrid.load({ metadata: [
{ name: "price", label:"Price", datatype: "double(CZK,2)", editable: true, },
{ name: "discount", label:"Dis.", datatype: "double(CZK,2)", editable: true, bar: false },
{ name: "count", label:"Pieces", datatype: "integer", editable: true, bar: false }
]});
This is not IMHO the best way to do this. 这不是恕我直言,做到这一点的最佳方法。 This way if you want to have 2 separate graphs (eg. price of product and number on stock), you can't do it, because you have stock count set not to show in graphs. 这样,如果您要拥有2个单独的图表(例如,产品价格和库存数量),则不能这样做,因为您已将库存数量设置为不在图表中显示。
Much nicer would be to modify the function, and pass into arguments array of columns, which you want to display, like so: 更好的方法是修改该函数,并将其传递给要显示的列的参数数组,如下所示:
editableGrid.renderCharts = function() {
this.renderBarChart("chart-graph", 'Prices', 'product_name', ['price_amount', 'discount'], {alpha: 0.75, bar3d: false});
};
Just saying, if any developer is looking 只是说,如果有开发人员正在寻找
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.