Comments (2)
Hi @ashishkanhasoft 👋
Thanks for pointing this out.
You can achieve the requested behaviour without using the pointerConfig
.
Instead, use the following props-
focusEnabled
showStripOnFocus
showDataPointLabelOnFocus
(this prop has been added in version1.4.11
)
Here's an example-
const App = () => {
const customTooltip = (value: number) => {
return (
<View
style={{
padding: 6,
borderWidth: 1,
borderColor: 'lightgray',
backgroundColor: 'white',
borderRadius: 8,
marginTop: -44,
marginLeft: -26,
}}>
<Text style={{color: 'gray', fontSize: 8, textAlign: 'center'}}>
Date here
</Text>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
width: 90,
marginTop: 10,
}}>
<View
style={{
height: 10,
width: 10,
borderRadius: 5,
backgroundColor: 'brown',
}}
/>
<Text style={{fontSize: 10, fontWeight: 'bold'}}>
{(value + 0.1).toFixed(1)}
</Text>
<Text style={{fontSize: 10, fontWeight: 'bold'}}>
{value.toFixed(2)}
</Text>
</View>
</View>
);
};
const values = [
{value: 0},
{value: 2},
{value: 1.8},
{value: 1.7},
{value: 3},
{value: 3.2},
{value: 2},
{value: 1.8},
{value: 1.7},
{value: 3},
];
const data = values.map(item => ({
...item,
dataPointLabelComponent: () => customTooltip(item.value),
}));
return (
<LineChart
data={data}
color="skyblue"
dataPointsColor="brown"
noOfSections={4}
maxValue={4}
focusEnabled
showStripOnFocus
showDataPointLabelOnFocus
/>
);
};
The output of the above code is-
Please use the latest version of the library.
from react-native-gifted-charts.
@Abhinandan-Kushwaha Thanks, It's working fine in a single-line chart, I want this multiline-chart, I am using pointerConfig to show a label tooltip like this,
Screen.Recording.2024-06-25.at.2.27.11.PM.mov
I have implemented your code in my multiline chart so horizontal scrolling all things works perfectly but here multilabel shows like this,
Screen.Recording.2024-06-25.at.1.19.59.PM.mov
<LineChart
areaChart
showFractionalValues={maxValue % 1 != 0}
yAxisLabelTexts={
// TODO: if maxValue is less then equal to 1 then its calculated
getYaxisLabels(maxValue, 10)
}
hideRules
verticalLinesColor={'#878787'}
verticalLinesThickness={1}
verticalLinesSpacing={50}
// focusEnabled
// showStripOnFocus
// showDataPointLabelOnFocus
// showVerticalLines
data={lineChart_1_New?.length > 0 ? lineChart_1_New : fakeData}
data2={lineChart_2_New}
data3={lineChart_3_New}
data4={lineChart_4_New}
data5={lineChart_5_New}
color1={lineChart_1_New?.length > 0 ? color1 : 'transparent'}
color2={color2}
color3={color3}
color4={color4}
color5={color5}
width={screen_width}
height={200}
spacing={70}
thickness={2}
dashGap={10}
dashWidth={8}
startOpacity={0}
endOpacity={0}
initialSpacing={40}
endSpacing={100}
noOfSections={4}
onlyPositive
maxValue={400}
yAxisThickness={0}
rulesColor="gray"
xAxisColor="lightgray"
yAxisTextStyle={{ fontSize: 10, color: '#7C8DB5', display: 'none' }}
yAxisLabelWidth={10}
xAxisLabelTextStyle={{ width: 80, height: 40, paddingTop: 10, fontSize: 10, color: '#7C8DB5' }}
xAxisThickness={0}
adjustToWidth
pointerConfig={{
pointerStripHeight: 120,
pointerStripColor: 'black',
pointerStripWidth: 2,
pointerColor: "transparent",
radius: 6,
pointerLabelWidth: 100,
pointerLabelHeight: 90,
activatePointersOnLongPress: true,
autoAdjustPointerLabelPosition: false,
stripOverPointer: true,
pointerVanishDelay: 3000,
initialPointerAppearDelay: 5,
activatePointersDelay: 150,
pointerEvents: 'auto',
showPointerStrip:
lineChart_1_New?.length > 0
|| lineChart_2_New?.length > 0
|| lineChart_3_New?.length > 0
|| lineChart_4_New?.length > 0
|| lineChart_5_New?.length > 0
? true : false,
pointerLabelComponent: items => {
return pointerComponentCustom(items);
},
}}
/>
So what I need to improve is the same label as per the first video can you please help me out, Thank you in Advance.
from react-native-gifted-charts.
Related Issues (20)
- BarChart with negative values and pointerConfig rendering incorrectly HOT 3
- verticalLinesStrokeDashArray property not being applied HOT 1
- cannot increase xAxis label width HOT 2
- Line Chart - Multiple secondary y axis data points possible? HOT 1
- Bar Chart not taking parent's full width (as it says on the docs) HOT 1
- BarChart accept positive decimal values as barDataItem but displayed in a strange scale HOT 1
- How to show decimals in y axis? HOT 1
- Scrolling BarChart does not seems to be working in React Native Web Development
- Using DataSet Line Chart, sometimes the color of the line is not drawn or unseen HOT 3
- Cannot read property 'style' of undefined, js engine: hermes HOT 1
- Bars slightly below horizontal rule lines HOT 4
- Want to show pointer from onpress event HOT 1
- Horizontal bar tooltip not rotated
- When using LineChart with specifying both dataSet and pointerConfig, "Cannot read property 'value' of undefined" error occurs
- Multiline chart CustomDataPoint Overflow issue. HOT 3
- Programmatically trigger the `onPress` event on BarChart
- yaxisLabel problem with negative values
- having the X-axis labels all on the same line
- Customization of the Y label text in LineChart
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-gifted-charts.