cube-js/cube

Unable to use shortTitle in .series()

Open

#673 aperta il 26 mag 2020

Vedi su GitHub
 (3 commenti) (2 reazioni) (0 assegnatari)Rust (1965 fork)batch import
client:corehelp wanted

Metriche repository

Star
 (19.563 star)
Metriche merge PR
 (Merge medio 5g 16h) (138 PR mergiate in 30 g)

Descrizione

In my ChartRenderer.js I was able to use shortTitle as seen below to remove the database prefix off of my table (antd) column titles.

  table: ({ resultSet }) => (
    <Table
      pagination={false}
      columns={resultSet.tableColumns().map(c => ({ title: c.shortTitle, key: c.key, dataIndex: c.key }))}
      dataSource={resultSet.tablePivot()}
    />
  )

When attempting to use this on my bar graph (chartjs) I was unable to get a similar result.

bar: ({ resultSet }) => {
    const data = {
      labels: resultSet.categories().map(c => c.category),
      datasets: resultSet.series().map((s, index) => ({
        label: s.shortTitle,
        data: s.series.map(r => r.value),
        backgroundColor: COLORS_SERIES[index],
        fill: false
      }))
    };
    const options = {
      scales: {
        xAxes: [
          {
            stacked: true
          }
        ]
      }
    };
    return <Bar data={data} options={options} />;

here is where I am hoping to expose shortTitle: https://github.com/cube-js/cube.js/blob/master/packages/cubejs-client-core/src/ResultSet.js#L74-L80

Guida contributor