@@ -1141,7 +1141,7 @@ export class SlopeChart
1141
1141
1142
1142
private renderSlopes ( ) {
1143
1143
return (
1144
- < >
1144
+ < g id = { makeIdForHumanConsumption ( "slopes" ) } >
1145
1145
{ this . renderSeries . map ( ( series ) => (
1146
1146
< Slope
1147
1147
key = { series . seriesName }
@@ -1151,7 +1151,28 @@ export class SlopeChart
1151
1151
outlineStroke = { this . backgroundColor }
1152
1152
/>
1153
1153
) ) }
1154
- </ >
1154
+ </ g >
1155
+ )
1156
+ }
1157
+
1158
+ private renderInteractiveSlopes ( ) : React . ReactElement {
1159
+ return (
1160
+ < g
1161
+ ref = { this . slopeAreaRef }
1162
+ onMouseMove = { this . onMouseMove }
1163
+ onTouchMove = { this . onMouseMove }
1164
+ onTouchStart = { this . onMouseMove }
1165
+ onMouseLeave = { this . onMouseLeave }
1166
+ >
1167
+ < rect
1168
+ x = { this . startX }
1169
+ y = { this . bounds . y }
1170
+ width = { this . endX - this . startX }
1171
+ height = { this . bounds . height }
1172
+ fillOpacity = { 0 }
1173
+ />
1174
+ { this . renderSlopes ( ) }
1175
+ </ g >
1155
1176
)
1156
1177
}
1157
1178
@@ -1176,7 +1197,7 @@ export class SlopeChart
1176
1197
const { xDomain, startX, endX } = this
1177
1198
1178
1199
return (
1179
- < >
1200
+ < g id = { makeIdForHumanConsumption ( "horizontal-axis" ) } >
1180
1201
< MarkX
1181
1202
label = { this . formatColumn . formatTime ( xDomain [ 0 ] ) }
1182
1203
x = { startX }
@@ -1193,32 +1214,6 @@ export class SlopeChart
1193
1214
labelPadding = { this . xLabelPadding }
1194
1215
fontSize = { this . yAxis . tickFontSize }
1195
1216
/>
1196
- </ >
1197
- )
1198
- }
1199
-
1200
- private renderChartArea ( ) {
1201
- return (
1202
- < g >
1203
- { this . renderYAxis ( ) }
1204
- { this . renderXAxis ( ) }
1205
- < g
1206
- id = { makeIdForHumanConsumption ( "slopes" ) }
1207
- ref = { this . slopeAreaRef }
1208
- onMouseMove = { this . onMouseMove }
1209
- onTouchMove = { this . onMouseMove }
1210
- onTouchStart = { this . onMouseMove }
1211
- onMouseLeave = { this . onMouseLeave }
1212
- >
1213
- < rect
1214
- x = { this . startX }
1215
- y = { this . bounds . y }
1216
- width = { this . endX - this . startX }
1217
- height = { this . bounds . height }
1218
- fillOpacity = { 0 }
1219
- />
1220
- { this . renderSlopes ( ) }
1221
- </ g >
1222
1217
</ g >
1223
1218
)
1224
1219
}
@@ -1284,6 +1279,30 @@ export class SlopeChart
1284
1279
)
1285
1280
}
1286
1281
1282
+ private renderInteractive ( ) : React . ReactElement {
1283
+ return (
1284
+ < >
1285
+ { this . renderYAxis ( ) }
1286
+ { this . renderXAxis ( ) }
1287
+ { this . renderInteractiveSlopes ( ) }
1288
+ { this . renderLineLegends ( ) }
1289
+ { this . renderNoDataSection ( ) }
1290
+ { this . tooltip }
1291
+ </ >
1292
+ )
1293
+ }
1294
+
1295
+ private renderStatic ( ) : React . ReactElement {
1296
+ return (
1297
+ < >
1298
+ { this . renderYAxis ( ) }
1299
+ { this . renderXAxis ( ) }
1300
+ { this . renderSlopes ( ) }
1301
+ { this . renderLineLegends ( ) }
1302
+ </ >
1303
+ )
1304
+ }
1305
+
1287
1306
render ( ) {
1288
1307
if ( this . failMessage )
1289
1308
return (
@@ -1297,14 +1316,9 @@ export class SlopeChart
1297
1316
</ >
1298
1317
)
1299
1318
1300
- return (
1301
- < g >
1302
- { this . renderChartArea ( ) }
1303
- { this . renderLineLegends ( ) }
1304
- { this . renderNoDataSection ( ) }
1305
- { this . tooltip }
1306
- </ g >
1307
- )
1319
+ return this . manager . isStatic
1320
+ ? this . renderStatic ( )
1321
+ : this . renderInteractive ( )
1308
1322
}
1309
1323
}
1310
1324
@@ -1336,10 +1350,7 @@ function Slope({
1336
1350
hover . background || focus . background ? 0.66 * strokeWidth : strokeWidth
1337
1351
1338
1352
return (
1339
- < g
1340
- id = { makeIdForHumanConsumption ( "slope" , seriesName ) }
1341
- className = "slope"
1342
- >
1353
+ < g id = { makeIdForHumanConsumption ( seriesName ) } className = "slope" >
1343
1354
{ showOutline && (
1344
1355
< LineWithDots
1345
1356
startPoint = { startPoint }
@@ -1411,22 +1422,16 @@ function GridLines({ bounds, yAxis }: GridLinesProps) {
1411
1422
{ yAxis . tickLabels . map ( ( tick ) => {
1412
1423
const y = yAxis . place ( tick . value )
1413
1424
return (
1414
- < g
1415
- id = { makeIdForHumanConsumption (
1416
- "grid-line" ,
1417
- tick . formattedValue
1418
- ) }
1425
+ < line
1426
+ id = { makeIdForHumanConsumption ( tick . formattedValue ) }
1419
1427
key = { tick . formattedValue }
1420
- >
1421
- < line
1422
- x1 = { bounds . left + yAxis . width }
1423
- y1 = { y }
1424
- x2 = { bounds . right }
1425
- y2 = { y }
1426
- stroke = "#ddd"
1427
- strokeDasharray = "3,2"
1428
- />
1429
- </ g >
1428
+ x1 = { bounds . left + yAxis . width }
1429
+ y1 = { y }
1430
+ x2 = { bounds . right }
1431
+ y2 = { y }
1432
+ stroke = "#ddd"
1433
+ strokeDasharray = "3,2"
1434
+ />
1430
1435
)
1431
1436
} ) }
1432
1437
</ g >
@@ -1450,7 +1455,14 @@ function MarkX({
1450
1455
} ) {
1451
1456
return (
1452
1457
< >
1453
- < line x1 = { x } y1 = { top } x2 = { x } y2 = { bottom } stroke = "#999" />
1458
+ < line
1459
+ id = { makeIdForHumanConsumption ( label ) }
1460
+ x1 = { x }
1461
+ y1 = { top }
1462
+ x2 = { x }
1463
+ y2 = { bottom }
1464
+ stroke = "#999"
1465
+ />
1454
1466
< text
1455
1467
x = { x }
1456
1468
y = { bottom + labelPadding }
0 commit comments