如何隐藏Google图表时间轴中的条形标签

时间:2016-03-14 16:18:00

标签: javascript charts google-visualization

我正试图从我的酒吧中删除标签(c1,c2,c3,c4)。

我试过造型: 03-15 10:06:58.074 14702-14702/com.example.app E/LoginFragment: Failed to decrypt password javax.crypto.IllegalBlockSizeException at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:486) at javax.crypto.Cipher.doFinal(Cipher.java:1502) at com.example.app.ui.fragment.util.LoginFragment.onAuthenticationSucceeded(LoginFragment.java:251) at com.example.app.ui.controller.FingerprintCallback.onAuthenticationSucceeded(FingerprintCallback.java:21) at android.support.v4.hardware.fingerprint.FingerprintManagerCompat$Api23FingerprintManagerCompatImpl$1.onAuthenticationSucceeded(FingerprintManagerCompat.java:301) at android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1.onAuthenticationSucceeded(FingerprintManagerCompatApi23.java:96) at android.hardware.fingerprint.FingerprintManager$MyHandler.sendAuthenticatedSucceeded(FingerprintManager.java:805) at android.hardware.fingerprint.FingerprintManager$MyHandler.handleMessage(FingerprintManager.java:757) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.security.KeyStoreException: Unknown error at android.security.KeyStore.getKeyStoreException(KeyStore.java:632) at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224) at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:473) at javax.crypto.Cipher.doFinal(Cipher.java:1502)  at com.example.app.ui.fragment.util.LoginFragment.onAuthenticationSucceeded(LoginFragment.java:251)  at com.example.app.ui.controller.FingerprintCallback.onAuthenticationSucceeded(FingerprintCallback.java:21)  at android.support.v4.hardware.fingerprint.FingerprintManagerCompat$Api23FingerprintManagerCompatImpl$1.onAuthenticationSucceeded(FingerprintManagerCompat.java:301)  at android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1.onAuthenticationSucceeded(FingerprintManagerCompatApi23.java:96)  at android.hardware.fingerprint.FingerprintManager$MyHandler.sendAuthenticatedSucceeded(FingerprintManager.java:805)  at android.hardware.fingerprint.FingerprintManager$MyHandler.handleMessage(FingerprintManager.java:757)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 但没有什么对我有用(我考虑将字体颜色设置为条形颜色,但文档说,你不能设置barLabel文本的颜色。“

jsfiddle:KeyGenParameterSpec

1 个答案:

答案 0 :(得分:1)

你可以使用 - > timeline: { showBarLabels: false }

google.charts.load('44', {
  callback: drawChart,
  packages: ['timeline']
});

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Activity', 'Category', 'Start Time', 'End Time'],

    ['Sleep', 'c1',
      new Date(2014, 10, 15, 12, 30, 0, 120),
      new Date(2014, 10, 15, 14, 30, 20, 550)
    ],

    ['Eat Breakfast', 'c2',
      new Date(2014, 10, 15, 12, 30, 55),
      new Date(2014, 10, 15, 14, 31, 55)
    ],

    ['Commute Home', 'c3',
      new Date(2014, 10, 15, 12, 29, 30),
      new Date(2014, 10, 15, 14, 30, 0)
    ],
    ['Commute Home', 'c4',
      new Date(2014, 10, 15, 14, 30),
      new Date(2014, 10, 15, 18)
    ]
  ]);

  var colors = [];
  var colorMap = {
    // should contain a map of category -> color for every category
    c1: '#e63b6f',
    c2: '#19c362',
    c3: '#592df7',
    c4: '#000000'
  }
  for (var i = 0; i < data.getNumberOfRows(); i++) {
    colors.push(colorMap[data.getValue(i, 1)]);
  }

  console.log(JSON.stringify(colors));

  var options = {
    height: 450,
    colors: colors,
    timeline: { showBarLabels: false }
  };

  var chart = new google.visualization.Timeline(document.getElementById('chart_div'));
  chart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>