cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.85k stars 1.77k forks source link

Unable to use shortTitle in .series() #673

Open Cmd-B opened 4 years ago

Cmd-B commented 4 years ago

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

keydunov commented 4 years ago

Hey @vasilev-alex @paveltiunov, just to give you some context here. We had a chat with @CMD-V in Slack and it seems that series() method doesn't expose the shortTitle property, while tableColumns() does.

It seems reasonable to have a consistent API for the these methods.

paveltiunov commented 4 years ago

Yeah. Agree.

paveltiunov commented 3 years ago

Contributions are welcomed here!