-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(D3 plugin): negative Y values for bar-x chart (#483)
* feat(D3): negative Y values for bar-x chart * Add bar-y and area chart examples with negative values * fix area chart * Fix bar-y * fix types
- Loading branch information
Showing
11 changed files
with
217 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
|
||
import {ChartKit} from '../../../../components/ChartKit'; | ||
import type {ChartKitWidgetData} from '../../../../types'; | ||
import {ExampleWrapper} from '../ExampleWrapper'; | ||
|
||
export const NegativeValues = () => { | ||
const data = [ | ||
{x: 0, y: 10}, | ||
{x: 1, y: 20}, | ||
{x: 2, y: -30}, | ||
{x: 3, y: 100}, | ||
]; | ||
|
||
const widgetData: ChartKitWidgetData = { | ||
series: { | ||
data: [ | ||
{ | ||
type: 'area', | ||
data: data, | ||
name: 'Min temperature', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
return ( | ||
<ExampleWrapper> | ||
<ChartKit type="d3" data={widgetData} /> | ||
</ExampleWrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
|
||
import {dateTime} from '@gravity-ui/date-utils'; | ||
|
||
import {ChartKit} from '../../../../components/ChartKit'; | ||
import type {ChartKitWidgetData} from '../../../../types'; | ||
import {ExampleWrapper} from '../ExampleWrapper'; | ||
import marsWeatherData from '../mars-weather'; | ||
|
||
export const NegativeValues = () => { | ||
const data = marsWeatherData.map((d) => ({ | ||
x: dateTime({input: d.terrestrial_date, format: 'YYYY-MM-DD'}).valueOf(), | ||
y: d.min_temp, | ||
})); | ||
|
||
const widgetData: ChartKitWidgetData = { | ||
series: { | ||
data: [ | ||
{ | ||
type: 'bar-x', | ||
data: data, | ||
name: 'Min temperature', | ||
}, | ||
], | ||
}, | ||
yAxis: [ | ||
{ | ||
title: { | ||
text: 'Min temperature', | ||
}, | ||
}, | ||
], | ||
xAxis: { | ||
type: 'datetime', | ||
title: { | ||
text: 'Terrestrial date', | ||
}, | ||
ticks: {pixelInterval: 200}, | ||
}, | ||
title: { | ||
text: 'Mars weather', | ||
}, | ||
}; | ||
|
||
return ( | ||
<ExampleWrapper> | ||
<ChartKit type="d3" data={widgetData} /> | ||
</ExampleWrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
|
||
import {dateTime} from '@gravity-ui/date-utils'; | ||
|
||
import {ChartKit} from '../../../../components/ChartKit'; | ||
import type {ChartKitWidgetData} from '../../../../types'; | ||
import {ExampleWrapper} from '../ExampleWrapper'; | ||
import marsWeatherData from '../mars-weather'; | ||
|
||
export const NegativeValues = () => { | ||
const data = marsWeatherData.map((d) => ({ | ||
y: dateTime({input: d.terrestrial_date, format: 'YYYY-MM-DD'}).valueOf(), | ||
x: d.min_temp, | ||
})); | ||
|
||
const widgetData: ChartKitWidgetData = { | ||
series: { | ||
data: [ | ||
{ | ||
type: 'bar-y', | ||
data: data, | ||
name: 'Min temperature', | ||
}, | ||
], | ||
}, | ||
xAxis: { | ||
title: { | ||
text: 'Min temperature', | ||
}, | ||
}, | ||
yAxis: [ | ||
{ | ||
type: 'datetime', | ||
title: { | ||
text: 'Terrestrial date', | ||
}, | ||
}, | ||
], | ||
title: { | ||
text: 'Mars weather', | ||
}, | ||
}; | ||
|
||
return ( | ||
<ExampleWrapper> | ||
<ChartKit type="d3" data={widgetData} /> | ||
</ExampleWrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.