New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v5] line transform groupX not works but it's ok in official example #4669
Comments
Can you give me a more complete example? Based on the information you provided, |
I think I have made a mistake, but how can I draw two lines in one chart? |
use .line() again to draw another line, I'll try it |
Here is an example. import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
autoFit: true,
paddingLeft: 50,
});
chart
.line()
.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/indices.json',
})
.encode('x', (d) => new Date(d.Date))
.encode('y', 'Close')
.encode('color', 'Symbol') // Color channel will group data by Symbol field, then draw one line for each group.
.scale('y', { type: 'log' })
.axis('y', { title: '↑ Change in price (%)' })
.label({
text: 'Symbol',
selector: 'last',
style: {
fontSize: 10,
},
});
chart.render(); |
This works fine too, and it is useful if the two lines encode different data. |
Maybe there should be a more simple example to draw multiple lines in one chart on the example page. |
No, you don't have to. Currently, G2 selects the closest datum point to the selected date. It looks like doesn't make sense in the situation you provided. I' will skip the missing point in the tooltip. |
now I use encode('series'...), is it the same effect?
The text was updated successfully, but these errors were encountered: