JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div class="parent">
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 130px; width: 270px;"></div>
</div>
CSS
.parent {
background-color: #000;
width: 300px;
padding: 30px;
}
#chartContainer {
margin: 30px auto 30px auto;
display: block;
}
.canvasjs-chart-tooltip {
max-width: 200px !important;
}
.canvasjs-chart-tooltip div {
max-width: 200px !important;
white-space: normal !important;
}
JavaScript
var chart = new CanvasJS.Chart("chartContainer", {
toolTip: {
shared: true,
fontFamily: "arial",
},
data: [
{
type: "line",
showInLegend: true,
name: "This is the last random sentence I will be writing and I am going to stop mid-sent",
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55 },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14 }
]
},
{
type: "line",
showInLegend: true,
name: "A purple pig and a green donkey flew a kite in the middle of the night and ended up sunburnt.",
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55 },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14 }
]
},
]
});
chart.render();