Kendo UI Angular 2+ Chart - Series Tooltip Template - Access to Category Value and Other Data -


i'm using kendo chart component series items of type "line".

according documentation here it's possible use current value placeholder within series tooltip template.

is there possibility access current category within template well? , in case i'm binding objects instead of primitive values possible access current data item not value?

thanks

there way. documentation provided not straightforward , found confusing well.

current category can accessed declaring variable , setting category.

if using object set data of kendo-chart-series-item, other properties of object can used tooltip. use dataitem property here access other properties of data have set.

  <kendo-chart-series-item-tooltip>         <ng-template let-value="value" let-category="category" let-dataitem="dataitem">           number of children: {{ dataitem.number }}         </ng-template>   </kendo-chart-series-item-tooltip> 

here each dataitem object array can set tooltip complete list of properties of tooltip can accessed can found here.

http://www.telerik.com/kendo-angular-ui/components/charts/api/tooltiptemplatepoint/#toc-category

working code

<kendo-chart>       <kendo-chart-tooltip>         <ng-template kendochartseriestooltiptemplate let-value="value">           default content {{ value }}         </ng-template>       </kendo-chart-tooltip>       <kendo-chart-title text="% children conscientious objection recorded"></kendo-chart-title>       <kendo-chart-category-axis>         <kendo-chart-category-axis-item           [categories]="['1999', '2000', '2001']"           [title]="{ text: 'years' }">         </kendo-chart-category-axis-item>       </kendo-chart-category-axis>       <kendo-chart-series>         <kendo-chart-series-item type="column" [data]="testdata" field="percent" >           <kendo-chart-series-item-tooltip>             <ng-template let-value="value" let-category="category" let-dataitem="dataitem">               number of children: {{ dataitem.number }}             </ng-template>           </kendo-chart-series-item-tooltip>          </kendo-chart-series-item>       </kendo-chart-series>  </kendo-chart> 

declare testdata object below in typescript file

testdata = [{       date: 1999,       percent: 0.23,       number: 4271     },     {       date: 2000,       percent: 0.41,       number: 7624     },     {       date: 2001,       percent: 0.55,       number: 9987     }] 

here using number attribute of object tooltip. hope helps. please let me know if not able solve it. happy help


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -