-
Notifications
You must be signed in to change notification settings - Fork 19.8k
Open
Labels
bugenThis issue is in EnglishThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.We are not sure about whether this is a bug/new feature.
Description
Version
6.0.0
Link to Minimal Reproduction
Steps to Reproduce
I have an SQL data source, which gives me data in the following form:
const sqlQuery = `
select generate_series::date as "date",
invoices.article_id,
sum(invoices.total_net) as sum_net
from generate_series('2025-01-01'::date, '2025-04-01'::date, '1 month'::interval)
join invoice_positions on date_trunc('month', invoice_positions.date) = generate_series::date
group by generate_series::date as date, invoices.article_id
`;
const sqlResult = [
['date', 'article_id', 'sum_net'],
['2025-01-01', 1, 100],
['2025-01-01', 2, 200],
['2025-01-01', 3, null],
['2025-02-01', 1, 101],
['2025-02-01', 2, 201],
['2025-02-01', 3, 301],
['2025-03-01', 1, null],
['2025-03-01', 2, null],
['2025-03-01', 3, 303],
['2025-04-01', 1, 104],
['2025-04-01', 2, null],
['2025-04-01', 3, 304]
];After some processing, I currently transfer this data to the client:
const fetchedData = {
columns: [
{ id: 'date', type: 'date' },
{ id: 'article_id', type: 'ref' },
{ id: 'sum_net', type: 'currency' }
],
rows: [
['2025-01-01', 1, 100],
['2025-01-01', 2, 200],
['2025-01-01', 3, null],
['2025-02-01', 1, 101],
['2025-02-01', 2, 201],
['2025-02-01', 3, 301],
['2025-03-01', 1, null],
['2025-03-01', 2, null],
['2025-03-01', 3, 303],
['2025-04-01', 1, 104],
['2025-04-01', 2, null],
['2025-04-01', 3, 304]
],
refs: {
article_id: [
[1, 'article 1'],
[2, 'article 2'],
[3, 'article 3']
]
}
};Now, to chart this data, I have two options: Either make a dataset, or embed data in the series:
dataset.source
const datasetSource = [
['date', 'article 1', 'article 2', 'article 3'],
['2025-01-01', 100, 200, null],
['2025-02-01', 101, 201, 301],
['2025-03-01', null, null, 303],
['2025-04-01', 104, null, 304]
];series[i].data
const seriesData = [
{
type: 'bar',
name: 'article 1',
stack: 'sum_net',
data: [
['2025-01-01', 100],
['2025-02-01', 101],
['2025-03-01', null],
['2025-04-01', 104]
]
},
{
type: 'bar',
name: 'article 2',
stack: 'sum_net',
data: [
['2025-01-01', 200],
['2025-02-01', 201],
['2025-03-01', null],
['2025-04-01', null]
]
},
{
type: 'bar',
name: 'article 3',
stack: 'sum_net',
data: [
['2025-01-01', null],
['2025-02-01', 301],
['2025-03-01', 303],
['2025-04-01', 304]
]
}
];Since dataset seems to be specifically for tabular data, this option make sense to me, so I try to setup a chart like this:
option = {
xAxis: { type: 'time' },
yAxis: {},
legend: {},
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
dataset: {
source: datasetSource,
seriesHeader: true
},
series: [
{ type: 'bar', stack: 'sum_net' },
{ type: 'bar', stack: 'sum_net' },
{ type: 'bar', stack: 'sum_net' }
]
};Using xAxis: { type: "time" } makes intuitively sense to me.
Current Behavior
The generated graph looks wrong in multiple places:
- The x axis starts at 1970-01-01
- Presumably, because some date is parsed as
null/NaN, which get re-interpreted asnew Date(0). Not entirely sure.
- Presumably, because some date is parsed as
- The legend labels are pair-wise concatenated ("date article 1" and "article 2 article 3").
- I have no clue as to how this could have happened.
Expected Behavior
Embedding the data in the series leads to the following graph:
Note:
- The x axis correctly shows the months, and
- The legend correctly shows three articles.
Environment
- OS: Debian 12 (that should not matter)
- Browser: Firefox 144.0, Chrome 141, Chrome 142 beta)
- Framework: noneAny additional comments?
No response
Metadata
Metadata
Assignees
Labels
bugenThis issue is in EnglishThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.We are not sure about whether this is a bug/new feature.