• <i id='letNE'><tr id='letNE'><dt id='letNE'><q id='letNE'><span id='letNE'><b id='letNE'><form id='letNE'><ins id='letNE'></ins><ul id='letNE'></ul><sub id='letNE'></sub></form><legend id='letNE'></legend><bdo id='letNE'><pre id='letNE'><center id='letNE'></center></pre></bdo></b><th id='letNE'></th></span></q></dt></tr></i><div id='letNE'><tfoot id='letNE'></tfoot><dl id='letNE'><fieldset id='letNE'></fieldset></dl></div>

      • <bdo id='letNE'></bdo><ul id='letNE'></ul>
      <tfoot id='letNE'></tfoot>
      1. <small id='letNE'></small><noframes id='letNE'>

        <legend id='letNE'><style id='letNE'><dir id='letNE'><q id='letNE'></q></dir></style></legend>

        更改图表的标签

        Changing the label of chart(更改图表的标签)
        <i id='ktpCy'><tr id='ktpCy'><dt id='ktpCy'><q id='ktpCy'><span id='ktpCy'><b id='ktpCy'><form id='ktpCy'><ins id='ktpCy'></ins><ul id='ktpCy'></ul><sub id='ktpCy'></sub></form><legend id='ktpCy'></legend><bdo id='ktpCy'><pre id='ktpCy'><center id='ktpCy'></center></pre></bdo></b><th id='ktpCy'></th></span></q></dt></tr></i><div id='ktpCy'><tfoot id='ktpCy'></tfoot><dl id='ktpCy'><fieldset id='ktpCy'></fieldset></dl></div>

        <small id='ktpCy'></small><noframes id='ktpCy'>

            • <bdo id='ktpCy'></bdo><ul id='ktpCy'></ul>
              <tfoot id='ktpCy'></tfoot>

                  <tbody id='ktpCy'></tbody>

              • <legend id='ktpCy'><style id='ktpCy'><dir id='ktpCy'><q id='ktpCy'></q></dir></style></legend>

                • 本文介绍了更改图表的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以在html中更改图表的标签.

                  Is it possible to change the labels of the chart in html.

                  我已经实现了一个圆环图.标签定义为

                  I have implemented a doughnut chart. the labels are defined as

                  public chartLabels = ["korea", "tokyo", "sydney"]
                  

                  我知道我可以在这里更改标签名称.

                  I understand I can change the label names here.

                  但我必须以标签根据语言选择进行翻译的方式来命名它.我像

                  but I have to name it in such a way that the label translates depending on the language selection. I do it in html like

                  {{'KOREA'|translate}}
                  

                  那么如何根据翻译需要更改标签

                  So how do I change labels for the translation needs

                  html中的标签是这样定义的

                  the labels in html are defined so

                   <canvas baseChart
                        [labels]="chartLabels"     
                        chartType="pie">
                   </canvas>
                  

                  推荐答案

                  你可能会使用这样的东西:

                  You could probably use something like this:

                  import {Component} from '@angular/core';
                  import {TranslateService} from '@ngx-translate/core';
                  
                  @Component({
                      selector: 'app',
                      template: `
                         <canvas baseChart
                            [labels]="chartLabels"     
                            chartType="pie">
                        </canvas>
                      `
                  })
                  export class AppComponent {
                      constructor(private translate: TranslateService) {};
                  
                      chartLabels = ["korea", "tokyo", "sydney"]
                      translatedChartLabels = []
                  
                      ngOnInit() {
                          this.translate.get(this.chartLabels)
                              .subscribe(translations => {
                                  /* translations is now an object with { 
                                   "key1": "translated value", 
                                   "key1": "translated value" } 
                                   and needs to be converted to an array again. */
                                  this.translatedChartLabels = Object.values(translations)
                          });
                      }
                  }
                  

                   <canvas baseChart
                        [labels]="translatedChartLabels"     
                        chartType="pie">
                   </canvas>
                  

                  这篇关于更改图表的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  • <bdo id='u0l11'></bdo><ul id='u0l11'></ul>
                    <tfoot id='u0l11'></tfoot>

                          <tbody id='u0l11'></tbody>
                        <i id='u0l11'><tr id='u0l11'><dt id='u0l11'><q id='u0l11'><span id='u0l11'><b id='u0l11'><form id='u0l11'><ins id='u0l11'></ins><ul id='u0l11'></ul><sub id='u0l11'></sub></form><legend id='u0l11'></legend><bdo id='u0l11'><pre id='u0l11'><center id='u0l11'></center></pre></bdo></b><th id='u0l11'></th></span></q></dt></tr></i><div id='u0l11'><tfoot id='u0l11'></tfoot><dl id='u0l11'><fieldset id='u0l11'></fieldset></dl></div>

                        <small id='u0l11'></small><noframes id='u0l11'>

                          • <legend id='u0l11'><style id='u0l11'><dir id='u0l11'><q id='u0l11'></q></dir></style></legend>