简体   繁体   English

ExtJS - 堆积条形图

[英]ExtJS - Stacked Bar Chart

How to offset the items in a stacked bar chart for any given bar?如何抵消任何给定条形图的堆积条形图中的项目?

Bar 1: 4 items (150,290,200,50)
Bar 2: only 2 items (--, --, 240,45)

I want to start the item with value 240 at a given offset instead of starting at 0 ( ex: I want to start it at 600 and show 240 from there).我想在给定的偏移量处以值 240 开始项目,而不是从 0 开始(例如:我想从 600 开始并从那里显示 240)。 From 0 to 600, it will be blank/white space.从 0 到 600,它将是空白/空白。

I can post my example code if that's of any help.如果有任何帮助,我可以发布我的示例代码。

Thank you.谢谢你。

There is no straight forward settings to do this.没有直接的设置可以做到这一点。 You will have to override the renderer and provide your custom styling to achieve the offset effect.您将必须覆盖渲染器并提供自定义样式以实现偏移效果。 The Ext.chart.series.Series does have a renderer method. Ext.chart.series.Series确实有一个renderer方法。

The method takes five parameters:该方法有五个参数:

  1. sprite - A class with all sprite information. sprite - 具有所有 sprite 信息的 class。
  2. record - The current record being rendered.记录 - 正在呈现的当前记录。
  3. attributes - Attributes used of the drawing. attributes - 绘图使用的属性。
  4. index - index of the record being processed. index - 正在处理的记录的索引。
  5. store - store used for the chart. store - 用于图表的存储。

You need to check if your record contains a null value.您需要检查您的记录是否包含 null 值。 If so, you need to modify the attributes object with appropriate values and return it back.如果是这样,您需要使用适当的值修改属性 object 并将其返回。 You can view the default renderer method from the source code.您可以从源代码中查看默认的渲染器方法

renderer: function(sprite,record,attributes,index,store) {
    //Modify the attributes object according to your needs 
    return attributes;
},

But I couldn't come up with a correct logic to modify the drawing values stored in attributes class.但是我想不出一个正确的逻辑来修改存储在属性 class 中的绘图值。

The record argument of the renderer function tells you which record is being rendered.渲染器 function 的记录参数告诉您正在渲染哪个记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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