简体   繁体   中英

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.

When using renderBarChart() function , the table renders a graph, but with all numeric columns (set in metadata as integer or double) as data. 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)?

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM